Archived

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

Megatron

Crazy font occurance

Recommended Posts

Okay, so my problem is this. When I use RenderFont in one place, it works okay. But when if I use it again later on, in another .cpp file, and specify a different size, the second RenderFont call''s size parameter is ignored. The placement is correct, but it ends up the size of the first one. The strange thing is, this size change only happens if I wait long enough. That is, if I run through the game sequence quickly, the fonts all appear the size they should be. Any help is greatly appreciated. Here is what my "font engine" looks like. //Declare our D3DXFont interface pointer ID3DXFont* fontPointer = NULL; extern IDirect3DDevice8* D3D_Device; void InitFont(int size) { HRESULT hr; //our LOGFONT structure defines the font we''re requesting. LOGFONT logFont={ size, //height 0, //width; 0, //lfEscapement; 0, //lfOrientation; FALSE, // lfWeight; FALSE, // lfItalic; FALSE, // lfUnderline; FALSE, // lfStrikeOut; DEFAULT_CHARSET, // lfCharSet; OUT_DEFAULT_PRECIS, //lfOutPrecision; CLIP_DEFAULT_PRECIS, // lfClipPrecision; ANTIALIASED_QUALITY,// lfQuality; DEFAULT_PITCH,// lfPitchAndFamily; "Times New Roman"// lfFaceName[LF_FACESIZE]; }; hr=D3DXCreateFontIndirect(D3D_Device,&logFont,&fontPointer); } void KillFont(void){ if(fontPointer) { fontPointer->Release(); fontPointer=NULL; } } void RenderFont(char* text, int xPosition, int yPosition, int size) { //We want the font to be formated to the whole screen RECT fontRect={0,0,800,600}; InitFont(size); fontPointer->Begin(); //Set the position for text rendering. fontRect.top = yPosition; fontRect.left = xPosition; fontPointer->DrawText(text,-1 , fontRect , DT_LEFT ,0xFFFFFFFF fontPointer->End(); }//end RenderFont()

Share this post


Link to post
Share on other sites