Sign in to follow this  

Problems with Dx9 Text

This topic is 3192 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, me again (:P) I have a problem with my Drawing of Text With DirectX, I am Attempting to setup a class 'cText'. which I can use, to Create a Font, and Draw it. Here is the Class Declaration :
class cText
{
private:
	LPD3DXFONT m_font;    // the pointer to the font object
public:
	cText();
	~cText();

	LPD3DXFONT Create(LPDIRECT3DDEVICE9 Device, UINT Height, UINT Width, bool Italic, LPCTSTR FontFace, LPD3DXFONT ppFont);
	bool Print(LPD3DXFONT ppFont, LPCSTR Text, long xPos, long yPos, long Width, long Height, BCOLOR TextColor);
	//bool Print(LPD3DXFONT ppFont, RECT textbox, BCOLOR TextColor);
};
and here is the Function Declaration : for Print.
bool cText::Print(LPD3DXFONT ppFont, LPCSTR Text, long xPos, long yPos, long Width, long Height, BCOLOR TextColor)
{
	static RECT textbox; SetRect(&textbox, xPos, yPos, Width, Height); 

	ppFont->DrawTextA(NULL, Text, -1, &textbox,
		DT_CENTER | DT_VCENTER, TextColor);
	return true;
}
here is where i call the Functions
//Font pre-defined cText Object
//Graphics pre-defined Graphics Object
bool cApp::Render()
{
	Font.Create(Graphics.GetD3DDevice(), 16, 0,false,L"Jokerman", dxfont);
	static RECT myBox; SetRect(&myBox, 0, 0, 640, 480); 
	Font.Print(dxfont, "MyText!", 0,0,640,480,C_WHITE);
	return true;
}
The Code all Compiles Properly, except, when i call the cText Function Print, the Project(i m using VC++ Express) breaks, and i get and error. I think Its with the RECT textbox, and my LPCSTR Text. //In red Text -- - &textbox 0x013db1a4 textbox {top=0 bottom=480 left=0 right=640} tagRECT * -Text 0x013d8778 "MyText!" const char *

Share this post


Link to post
Share on other sites

This topic is 3192 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this