Jump to content
  • Advertisement

Archived

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

IKLOP

DrawText problem

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

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
Make sure you are calling pFont->OnLostDevice when your device gets lost, and pFont->OnResetDevice when you successfully reset the device.

xyzzy

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!