DrawText problem

Started by
5 comments, last by IKLOP 20 years, 6 months ago
I''ve added a frame rate to my app and I use ID3DXFont to display it. When I run the program it runs fine, but when I minimize the program by pressing alt+tab, then restore it it immediately crashes. If I take out the DrawText line then it works fine, so thats where the problem is. I''ve tried a couple different things, but I''m pretty new to DirectX so they were mostly guesses which never seem to work. Any ideas? Thanks, -Steve
Advertisement
Post the code dude, we can''t help blindfolded
_________ Evious Ltd.
This is my render functions:
[sourcee]
int Render()
{
HRESULT r = 0;

// Make sure the device is valid
if( !g_pDevice )
{
return E_FAIL;
}

// Return if the device is not ready;
r = ValidateDevice();
if( FAILED( r ) )
{
return E_FAIL;
}

g_pDevice->Clear( 0, 0, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0 ), 1.0f, 0 );

FrameCount();

if( SUCCEEDED( g_pDevice->BeginScene() ) )
{
char string[4]; // String to hold the frame rate
ZeroMemory( &string, sizeof( string ) );
itoa( g_FrameRate, string, 10 );

RECT rc;
SetRect( &rc, 10, 10, 100, 500 );
g_pFont->DrawText( string, -1, &rc, DT_WORDBREAK, D3DCOLOR_ARGB(255, 255, 255, 255) );

g_pDevice->EndScene();
}

r = g_pDevice->Present( NULL, NULL, NULL, NULL );

return S_OK;
}
[/source]

If I take out g_pFont->DrawText( string, -1, &rc, DT_WORDBREAK, D3DCOLOR_ARGB(255, 255, 255, 255) );
then I can minimize and restore fine.

Thanks
Is g_pFont being destroyed/correctly restored?

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Check the thing Endurion said, but if that does not work, try to create a bigger buffer for the string.

[How To Ask Questions|STL Programmer''s Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN]
Arguing on the internet is like running in the Special Olympics: Even if you win, you're still retarded.[How To Ask Questions|STL Programmer's Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN]
I had not restored the font. Got it working now. Thanks.
Make sure you are calling pFont->OnLostDevice when your device gets lost, and pFont->OnResetDevice when you successfully reset the device.

xyzzy

This topic is closed to new replies.

Advertisement