Draw text with directx functions: ?
ok i tried this
ID3DXFont* pFont;
LPCTSTR Tfont="Arial";
D3DXCreateFont(device,
15, 0, FW_BOLD,1,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE , Tfont, &pFont );
//in rendering loop
pFont->DrawText (NULL, sring, -1, rect, DT_CENTER, D3DCOLOR_ARGB(0,0,0,0));
but never is drawn .....i need help
ID3DXFont* pFont;
LPCTSTR Tfont="Arial";
D3DXCreateFont(device,
15, 0, FW_BOLD,1,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE , Tfont, &pFont );
//in rendering loop
pFont->DrawText (NULL, sring, -1, rect, DT_CENTER, D3DCOLOR_ARGB(0,0,0,0));
but never is drawn .....i need help
Baf,
I'm sure your way works fine, I've just never tried your method before. I always use the following to create the font:
As well, you dont show in your example what you have for "rect" that gets passed into the DrawText function. If rect isnt set appropriately, the text wont show.
Cheers! Jeromy
I'm sure your way works fine, I've just never tried your method before. I always use the following to create the font:
D3DXFONT_DESC font;font.Height = 20;font.Width = 10;font.Weight = 500;font.Italic = false;font.OutputPrecision = 3;font.Quality = 1;font.PitchAndFamily = 34;strcpy( font.FaceName, "Arial" );font.MipLevels = 1; if( FAILED( D3DXCreateFontIndirect( g_pd3dDevice, &font, &g_pFont ) ) ) return -1;
As well, you dont show in your example what you have for "rect" that gets passed into the DrawText function. If rect isnt set appropriately, the text wont show.
Cheers! Jeromy
Tutorial on rendering text(from www.drunkenhyena.com):
http://www.drunkenhyena.com/cgi-bin/view_cpp_article.pl?chapter=3;article=17
http://www.drunkenhyena.com/cgi-bin/view_cpp_article.pl?chapter=3;article=17
Quote://in rendering loop
pFont->DrawText (NULL, sring, -1, rect, DT_CENTER, D3DCOLOR_ARGB(0,0,0,0));
Could it be your alpha?
Quote:Could it be your alpha?
lol...nice catch Bliz23, didnt even see that. That may not be his only problem, but an alpha of 0 would definately cause nothing to show up. =)
Rating++ for Bliz23.
alpha ranges from 0 to 255, so there isn't much noticable difference between 0 and 1. Also, what's your screen color? if it's black then you still wont see anything since your font color is set to black. Try using something like: D3DCOLOR_ARGB( 255, 0, 0, 255 )
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement