Jump to content
  • Advertisement
Sign in to follow this  

Resizing and LPD3DXFONT causing BeginScene to fail every other time

This topic is 4906 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'm making a game w/ DirectX 9 and C++. I just added some code to use some directx fonts along the lines of:
void Game::InitializeFonts() {

	int nHeight;
	int nPointSize = 18;

	hDC = GetDC( NULL );

	nHeight = -( MulDiv( nPointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72 ) );
	hr = D3DXCreateFont( g_pd3dDevice, nHeight, 0, FW_BOLD, 0, FALSE, 
		                 DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"), 
		                 &m_pd3dxFont );

RECT destRect1;
SetRect( &destRect1, 300, 300, 0, 0 );
m_pd3dxFont->DrawText( NULL,TEXT("Game Over. Press Any Key To Restart"), -1, &destRect1, DT_NOCLIP, D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f) );
but when I would resize, the BeginScene would fail with an error code of D3DERR_INVALIDCALL. But the really weird thing was that if I resized again, everything would go back to normal. My resize handling code is reseting the device and reinitializing the fonts and whatnot. So I finally tried adding a second call to the device's reset function and that fixed it.
g_pd3dDevice->Reset( &d3dpp );
g_pd3dDevice->Reset( &d3dpp );
But it's a total hack. Does anybody have an idea of why this might happen?

Share this post

Link to post
Share on other sites
Sign in to follow this  

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