Jump to content
  • Advertisement
Sign in to follow this  
ultimastrike

Reset Problems

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

I'm attempting to detect and restore a lost d3d device using the following method: In WindowProc I have the case
case WM_ACTIVATEAPP:
{
     if(wParam)
          ResetDevice();
     return 0;
} break;

And the ResetDevice function looks like this
void ResetDevice()
{     HRESULT result = NULL;
      if(d3ddev)
           result = d3ddev->Reset(&d3dpp);
      return;
}

I have added tracepoints to the ResetDevice function and am certain that it is being called. The hresult returned evaluates as S_OK by my tracepoint. So what I'm wondering is, why does my screen remain black? The tutorial I'm following at directxtutorials.com doesn't provide any additional steps.

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure, but I think it's generally more reliable to use IDirect3DDevice9::TestCooperativeLevel to test whether the device needs to be reset.

Regardless of how you detect whether you need to reset or not, you need to be aware that you need to recreate all your un-managed resources. This includes any d3d objects you created with D3DPOOL_DEFAULT, and generally quite a few of the D3DX interfaces require that you call some kind of OnLostDevice/OnResetDevice methods.

So, first

detect that device is lost
call OnLostDevice for all relevant objects
recreate objects that need it
call OnResetDevice for all relevant objects

Hope that helps...

Share this post


Link to post
Share on other sites
I'm not sure I made any objects with that flag. Is it implicit?

I have several textures, a model and some custom vertex objects floating around before I tab out. Is there an easy way to tell which ones I need to recreate, or should I just release and remake all of them?

Share this post


Link to post
Share on other sites
Most of the resource creation methods (i.e., device->CreateTexture, device->CreateVertexBuffer, etc.) take a D3DPOOL type as one of the parameters. Check and see what you're passing to those methods.

Also, there's a good section in the DX docs entitled Lost Devices, you might do a search in there to see what it says.

Share this post


Link to post
Share on other sites
If things needed OnLostDevice or were in POOL_DEFAULT, the Reset would have failed. I'm guessing the bug is elsewhere, but those are good things to be aware of doing.

Enable the debug runtime. Run. Check your output window. Perhaps whatever is failing will show up here.

If you follow lots of online samples, they tend to be written horribly. Many set renderstates, projection matrices, and sometimes even vertex and index buffers only once during init. When you reset, the device state is lost. Unless you set these again after reset, nothing will work as expected.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!