#### Archived

This topic is now archived and is closed to further replies.

# ID3DXFont Troubles

## Recommended Posts

Grizwald    270
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?

##### Share on other sites
__Daedalus__    480
Are you rendering your text between the calls to

Device->BeginScene();

and

Device->EndScene();

?

##### Share on other sites
xyzzy00    307
Passing in DT_CALCRECT tells it to update the rectangle, but not draw anything.

xyzzy

##### Share on other sites
Mike29936    132
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.

##### Share on other sites
Grizwald    270
well, I tried a different flag, and set the rectangle manually, and i still got nothing

##### Share on other sites
xyzzy00    307
Your next problem is that you are specifying 0x00FFFFFF for the color.. transparent white. Try 0xFFFFFFFF instead.. opaque white.

xyzzy

##### Share on other sites
Grizwald    270
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!!!