Sign in to follow this  
JClayton

Resetting the Device

Recommended Posts

I am having trouble resetting the display device. I know that Present() returns an error if the device is lost so I call Reset() on the device with an in-class-stored D3DPRESENT_PARAMETERS structure. The code used is as follows:
bool cVideo::EndFrame()
{
  HRESULT result;
  
  if(SUCCEEDED(m_device->EndScene())) 
    if(SUCCEEDED(result = m_device->Present(NULL, NULL, NULL, NULL)))
      return true;
    else
    {
      if(result == D3DERR_DEVICELOST)
        m_device->Reset(&m_present);
    }
   
  return false;
}
I have no resources loaded and the default screen color is grey and is cleared to black at the beginning of the frame. However when the device is lost the screen is no longer cleared as it should be. Just for reference, the code to begin the scene is as follows:
bool cVideo::BeginFrame()
{
  if(SUCCEEDED(m_device->Clear(0, NULL, D3DCLEAR_TARGET, SYS_ColorBlack, 1.0f, 0)))
    if(SUCCEEDED(m_device->BeginScene()))
      return true;
  
  return false; 
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this