Jump to content
  • Advertisement
Sign in to follow this  
lodoss118

Directx lost device, clear screen?

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

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?

// 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]



Share this post


Link to post
Share on other sites
Advertisement
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.

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!