Drawing Text - DirectX9

Started by
9 comments, last by Magmatwister 14 years, 1 month ago
Quote:Original post by Evil Steve
The Debug Runtimes will tell you when a function fails and why it failed. However, for proper code, you should be checking the return value of every single function that creates an interface or returns information you rely on using the SUCCEEDED or FAILED macros.

The TEXT() macro is needed if you want to write code that will build as Unicode or non-Unicode.

The only reason that D3DXCreateFont would crash would be if your device pointer was invalid (Not NULL, but already Release()d or something). Your Debugger will tell you exactly what's wrong.


Thank you! You were right! Well, sort of, what was happening was I was calling the initialise font function BEFORE I had set up directx properly.

I was doing:

InitialiseFonts()
WIDTH = WIN_WIDTH;
HEIGHT = WIN_HEIGHT;
WIN_STATE = WINDOWED;

D3D = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS PARAMS;
ZeroMemory(&PARAMS, sizeof(PARAMS));
PARAMS.BackBufferHeight = WIN_HEIGHT;
PARAMS.BackBufferWidth = WIN_WIDTH;

// etc etc etc etc etc

Instead of:

D3DDEV->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
InitialiseFonts();

(The last thing I do in setting up direct x is setting the render states)

Thus when I tried to use the directx device (D3DDEV) when creating my font, It failed because it had not yet been filled. Thanks for your help, I will try to use the debugger in my future problems.
Currently trying to make a planet renderer. After many hours of work, somehow I know It'll never be complete.
Also, If I help you, please give me an ++

This topic is closed to new replies.

Advertisement