// 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
}
}
}
Problem with my Lost Device handling method (C++)
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)
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
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(); }}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement