Archived

This topic is now archived and is closed to further replies.

FrikkaSoft

A Font question

Recommended Posts

I have a problem drawing text using the D3DXCreateFont function. I figured out that the problem lies in this function. Everything compiles fine but the program won´t execute. it look´s like this: if ( FAILED( D3DXCreateFont( g_pd3dDevice, ?, g_pFont))) return E_FAIL; You can see that I put a ? where the handle to the font object is supposed to be. I tried NULL, 0 and HFONT. But nothing.. The SDK does not explain the handle to the font object HFONT in enough detail. Does anyone know a tutorial about the D3DXFONT interface.

Share this post


Link to post
Share on other sites
hehe.. Well the point of the D3DXCreateFont is to create a d3d version of a Windows font so the second parameter is a handle to a windows font. Try this

D3DXCreateFont ( g_pd3dDevice, (HFONT)GetStockObject ( SYSTEM_FONT ), &g_pFont );

Now there are two things that are different. The second parameter which loads a windows system font and the third parameter which takes a Pointer to a Pointer of type D3DXFont. Now from your declaration of g_pFont I assume you declared it like this LPD3DXFONT g_pFont. So you need to pass in the that pointer &g_pFont..

Hope this helps

------
Andrew T. Finnell
Software Engineer
e-Security Inc.

Share this post


Link to post
Share on other sites
If you don''t want to use a stock system font, use CreateFont() or CreateFontIndirect() with the parameters you want. In general, everything can be zero except for height, weight and the typeface (Arial, Tahoma, etc)

Share this post


Link to post
Share on other sites