Problems with Dx9 Text

Started by
1 comment, last by Andy474 15 years, 1 month ago
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 *
Advertisement
Your Create() function takes a LPD3DXFONT, not a LPD3DXFONT& (or LPD3DXFONT*), so you're not "returning" any value through it. You should use LPD3DXFONT& in the function instead.
Thanks, though it'd be summin stupid like that :)

This topic is closed to new replies.

Advertisement