Schrift spielt verrückt
-
Hi!
Ich hab mir mal 2 Funktionen zur Textausgabe gebastelt, aber die spielen irgendwie verrückt!
Wenn man die Maus ca. 30 s nicht mehr bewegt, verändern sich die Schriften auf dem Bildschirm(nicht mehr fett gedruckt, kleiner als angegeben, usw...).
Weiß jemand woran das liegen kann?
Hier nochmal die 2 Funktionen:
/* * Funktion für die Textausgabe */ LPD3DXFONT Font; HFONT hFont; bool SetFont( LPCSTR szFontName, int iFontSize, bool bItalic, bool bBold, bool bUnderlined ) { if( bBold ) hFont = CreateFont( iFontSize, 0, 0, 0, FW_BOLD, bItalic, bUnderlined, 0, 0, 0, 0, 0, 0, szFontName ); else hFont = CreateFont( iFontSize, 0, 0, 0, 0, bItalic, bUnderlined, 0, 0, 0, 0, 0, 0, szFontName ); if( !hFont ) return FALSE; D3DXCreateFont( lpD3DDevice, hFont, &Font ); if( !Font ) return FALSE; return TRUE; } bool DrawText( int X1, int X2, int Y1, int Y2, LPCSTR Text, int style, int r, int g, int b ) { RECT rect; rect.bottom = Y2; rect.left = X1; rect.right = X2; rect.top = Y1; if( !Font->DrawText( Text, -1, &rect, style, D3DCOLOR_XRGB( r, g, b ) ) ) return FALSE; return TRUE; }
-
Sorry! Ich hab den Fehler schon selber gefunden
! Man muss einfach bloß immer bevor mach SetFont() einsetzt die Beiden Variablen auf NULL setzen:/* * Funktion für das wiederbereitmachen der Schrift */ void ResetFont() { hFont = 0; Font->Release(); }