ID3DXFont Troubles

Started by
5 comments, last by Grizwald 19 years, 11 months ago
Well I''m getting back to my D3D engine, and I''m going to use ID3DXFont for text.

LOGFONT LogFont;

// Clears out font''s memory

ZeroMemory(&LogFont, sizeof(LOGFONT));
	
// Sets the font''s basic parameters

strcpy(LogFont.lfFaceName, "Arial");
LogFont.lfHeight = 12;

// Creates font object and checks if it went ok

if(FAILED(D3DXCreateFontIndirect(Direct3DDevice, &LogFont, &Direct3DFont)))
{
    MessageBox(NULL, "Error With Font System", "ERROR", NULL);
    return false;
}
	
	
there is my initialization function. Here is my text drawring function

RECT r;
SetRect( &r, x, y, 0, 0 );	

Direct3DFont->Begin();
Direct3DFont->DrawText ("HI",-1,&r,DT_CALCRECT,0xFFFFFF);
Direct3DFont->End();
I get nothing. MY device is created without any exceptions (I can render meshes and whatnot) and Direct3DFont is created without failure. So WTF?
I love me and you love you.
Advertisement
Are you rendering your text between the calls to

Device->BeginScene();

and

Device->EndScene();

?
Passing in DT_CALCRECT tells it to update the rectangle, but not draw anything.

xyzzy
quote:Direct3DFont->DrawText ("HI",-1,&r,DT_CALCRECT,0xFFFFFF);


You have DT_CALCRECT for drawing.

quote:Determines the width and height of the rectangle. If there are multiple lines of text, ID3DXFont::DrawText uses the width of the rectangle pointed to by the pRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, ID3DXFont::DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, ID3DXFont::DrawText returns the height of the formatted text but does not draw the text.
well, I tried a different flag, and set the rectangle manually, and i still got nothing
I love me and you love you.
Your next problem is that you are specifying 0x00FFFFFF for the color.. transparent white. Try 0xFFFFFFFF instead.. opaque white.

xyzzy
quote:Original post by xyzzy00
Your next problem is that you are specifying 0x00FFFFFF for the color.. transparent white. Try 0xFFFFFFFF instead.. opaque white.

xyzzy


Thank you so much! I can''t believe I didn''t think of that. I''m using 32 bits so it makes a lot of sense! Your help is GREATLY appreciated!!!
I love me and you love you.

This topic is closed to new replies.

Advertisement