Archived

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

IKLOP

DrawText problem

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
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