Archived

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

Shambles

Restoring lost D3D

Recommended Posts

Shambles    122
Hi, My attemps at restoring the lost D3D object ends with an unexpected quit from my application. Whenever I want to start drawing I use this:
  void CGraphics::BeginRender(void) {
	#ifdef _WIN32
	if (Device->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
		Reset();
		while (Device->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {}
	}

	Device->BeginScene();
	#endif//_WIN32

}  
As you can see, it is supposed to deal with lost devices (or at least supposed to deal with them.. according to the limited, lack-of source examples of the DirectX SDK documentation. Thanks in advance, -Shambles

Share this post


Link to post
Share on other sites
mickey    100
hi,

you could check their dx common files on how they handle it, anyway it looks similar to this,


if(FAILED(hr = m_pd3dDevice->TestCooperativeLevel()))
{
// If the device was lost, do not render until we get it back
if(hr == D3DERR_DEVICELOST)
return true;
// Check if the device needs to be reset.
if(hr == D3DERR_DEVICENOTRESET)
{
if(ReInitializeGameData() == false)
return false;
}
return true;
}


Share this post


Link to post
Share on other sites
Lupin    122
This restores an lost device (VB-code):

If D3Ddevice.TestCooperativeLevel = D3DERR_DEVICELOST Then ''Device was lost
Set DXfont = Nothing ''Destroy all fonts
Do
If D3Ddevice.TestCooperativeLevel = D3DERR_DEVICENOTRESET Then ''Device needs to be reset
frmMain.WindowState = vbMaximized
Call D3Ddevice.Reset(D3DWindow)
SetupDevice ''Setup the lost stuff (if there''s something created not using MANAGED-Memory handling)
Exit Do
End If
DoEvents
Loop
End If

Share this post


Link to post
Share on other sites