Advertisement Jump to content
Sign in to follow this  


This topic is 4876 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

Simply put, it renders text. Example usage (from my source):

LPDIRECT3DDEVICE9 pDevice; // A valid D3D Device
ID3DXFont* pFont = NULL;

// Create a bold, size 16 Ariel font //
HRESULT hResult = D3DXCreateFont(pDevice,16,0,FW_BOLD,1,FALSE,ANSI_CHARSET,
char szBuff[256];
sprintf(szBuff,"D3DXCreateFont() failed. Error: 0x%08X",hResult);
return false;

// ...
// Other setup code here
// ...

// At rendering time...
RECT rc = {0,0,1024,768}; // Rectangle to draw text in

// Draw some yellow text //
pFont->DrawText(NULL,"Hello World!",-1,&rc,DT_LEFT|DT_TOP,0xffffff00);

And be sure to Release() your fint when you're done. Also, you need to call OnLostDevice() and OnResetDevice() when you lose your device, and after you reset your device.

Hope this helps.

Share this post

Link to post
Share on other sites
For information on what all of those crazy parameters for D3DXCreateFont mean, go here. Almost exactly halfway down the page is a section titled "The Logical Font Structure". The members of that structure correspond to the 2nd through 11th parameters to the function.

Share this post

Link to post
Share on other sites
Original post by ArchangelMorph
Ok cool, so I can actually use windows truetype fonts with this program?

Bingo. Any font that windows can use via CreateFont/CreateFontIndirect, you can use with D3DXCreateFont/D3DXCreateFontIndirect. The D3DX and Win32 versions of these functions are very similar. Also, the D3DX and Win32 DrawText functions are similar as well.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!