A Font question

Started by
1 comment, last by FrikkaSoft 22 years, 9 months ago
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.
Friðrik Ásmundsson
Advertisement
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.
------Andrew T. FinnellSoftware Engineere-Security Inc.
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)

This topic is closed to new replies.

Advertisement