// Reload data if device is lost
if ( lpd3dDevice->TestCooperativeLevel() != D3D_OK )
{
//if ( dxuSystemInfo.releasePrimitivesProc != NULL )
// dxuSystemInfo.releasePrimitivesProc();
//lpd3dDevice->Reset(&dxuSystemInfo.d3dpp);
//if ( dxuSystemInfo.loadPrimitivesProc != NULL )
// dxuSystemInfo.loadPrimitivesProc();
}
// Clear the backbuffer to a generic color
lpd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, dxuSystemInfo.bkColour, 1.0f, 0 );
// Begin the scene
lpd3dDevice->BeginScene();
/source]
Directx lost device, clear screen?
Hi in the wrapper i am using i have a method called
DXURenderPrepare() and DXUFinishRender(), basically this starts up the double buffering etc
When pressing thewindows key and L key i.e going to the login screen, the device is lost and the scene goes black
is there any easier way oto get the device back and keep rendering?
In simple terms, no, there is no easier way. It is conventional to check every frame for a lost device and, if so, release dynamic resources, poll restoring the device until successful, then recreating the resources.
In practice, some D3D resources can be created in such a way that they do not need restoring after a device reset. For example, creating a texture with D3DPOOL_MANAGED means that it is duplicated in system memory so does not need to be restored in these cases.
Unless there is a problem reloading your resources though, I really wouldn't worry about it. It will only happen very rarely and the cost of testing in frames where the device has not been lost is so minimal as to be irrelevant. I don't know how all this DXUStuff works, but your code looks fine to me.
In practice, some D3D resources can be created in such a way that they do not need restoring after a device reset. For example, creating a texture with D3DPOOL_MANAGED means that it is duplicated in system memory so does not need to be restored in these cases.
Unless there is a problem reloading your resources though, I really wouldn't worry about it. It will only happen very rarely and the cost of testing in frames where the device has not been lost is so minimal as to be irrelevant. I don't know how all this DXUStuff works, but your code looks fine to me.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement