Jump to content
  • Advertisement
Sign in to follow this  
dist0rted

Problem with my Lost Device handling method (C++)

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

My code doesn't really work at all. I create a full screen application, ALT+TAB out of it, Restore it from the Start Menu, and I get the plain white Win32 Window I created (without Direct3D initiated - which sets the screen black) Alrighty, this code is what I put in my main loop: (After I handle Window input, and before I render anything)
// Handle Lost Device:
hResult = m_pd3dDevice->TestCooperativeLevel();
if (FAILED(hResult))
{
	// Check if Device is Lost:
	if (hResult = D3DERR_DEVICELOST)
	{
		Sleep(100); // Rest the Program for a Bit
	}
	else
	{
		InvalidateDeviceOjbects(); // Shutdown User Defined data in this function
				
		if (m_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICELOST)
		{
			Sleep(100); // Device is still lost
		}
		else
		{
			RestoreDeviceObjects(); // Re-Init User Data in this Function
		}
	}
}

Share this post


Link to post
Share on other sites
Advertisement
Doesn't look like your reseting the device first, is the m_pd3dDevice->Reset call inside RestoreDeviceObjects()?

Also (hResult = D3DERR_DEVICELOST) is the one = a typo? shouldn't really effect outcome though as it would just execute the else part of the if-else.

Heres the reset code from a project of mine

The m_pCurrentpresentParameters is saved in the class from when D3D is initialized


else if( hr == D3DERR_DEVICENOTRESET )
{
// release all d3dpool_default members before reset
OnDeviceLost();

hr = m_pDevice->Reset(&m_pCurrentpresentParameters);

if( hr == D3D_OK )
{
m_bDeviceLost = false;
// recreate all d3dpool_default members
OnDeviceReset();
}
}

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!