Jump to content
  • Advertisement
Sign in to follow this  
Baf

Draw text with directx functions: ?

This topic is 4844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

is it possible to draw simple text using some avaible functions of dx? Whaz the best way?

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Quote:
//in rendering loop
pFont->DrawText (NULL, sring, -1, rect, DT_CENTER, D3DCOLOR_ARGB(0,0,0,0));

Could it be your alpha?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 )

Share this post


Link to post
Share on other sites
YEEEES it works
i was stupid i can't see nothing with alpha 1!!!!

thanks!!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!