Draw text with directx functions: ?

Started by
8 comments, last by Baf 18 years, 8 months ago
is it possible to draw simple text using some avaible functions of dx? Whaz the best way?
Baffo"role-game needs a table"
Advertisement
see d3dx doc -> ID3DXFont
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
Baffo"role-game needs a table"
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:
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
Jeromy Walsh
Sr. Tools & Engine Programmer | Software Engineer
Microsoft Windows Phone Team
Chronicles of Elyria (An In-development MMORPG)
GameDevelopedia.com - Blog & Tutorials
GDNet Mentoring: XNA Workshop | C# Workshop | C++ Workshop
"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - Il Duche, Boondock Saints
Tutorial on rendering text(from www.drunkenhyena.com):
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.
Jeromy Walsh
Sr. Tools & Engine Programmer | Software Engineer
Microsoft Windows Phone Team
Chronicles of Elyria (An In-development MMORPG)
GameDevelopedia.com - Blog & Tutorials
GDNet Mentoring: XNA Workshop | C# Workshop | C++ Workshop
"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - Il Duche, Boondock Saints
Isn't my alpha i tried 1 with and never shown

Baffo"role-game needs a table"
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 )
[size=2]aliak.net
YEEEES it works
i was stupid i can't see nothing with alpha 1!!!!

thanks!!
Baffo"role-game needs a table"

This topic is closed to new replies.

Advertisement