Jump to content
  • Advertisement
Sign in to follow this  
Moe

Getting bad values on D3DDevice-Reset() after Alt-Tab...

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

Hey all, I seem to have run into yet another minor technical problem with the program that I am working on. Being a good programmer, I am trying to set my program up so that it handles an Alt-Tab situation gracefully. So far, I have been able to Alt-Tab out of the program (when it is running fullscreen), but the minute that I go back in, all heck seems to break loose. (Okay, so maybe that is a bit of an exaggeration[rolleyes]). Anyway, after Alt-Tabbing back into the program, it crashes. I have been running it through the debugger to see what I can catch, and it appears that the D3DDevice->Reset() method is giving me back an invalid return type. I ran it through the debugger a few more times to see if everything valid was being passed in, and so far it looks decent. The only one that seemed that it was perhaps out of place was the handle to the window. Do I need to pass in a fresh handle to the window after an Alt-Tab? Any other thoughts on what could be causing the Reset() method to botch? (I would post code, but it is a bit lengthy, although I can do so if you desire).

Share this post


Link to post
Share on other sites
Advertisement
Use the debugger to see where/why does it crash and tell us.

Also, be sure to release any resources created with the D3DPOOL_DEFAULT flag before calling Reset() on the device.

Share this post


Link to post
Share on other sites
Well, so far the only resources I am using are created in the D3DXFont system, and I am not sure how it stores things internally.

I managed to prevent it from crashing. I noticed that I wasn't checking the return type on my Reset() method when I should have been. So, I got that solved. Now I just need to figure out why my D3DDevice->Reset is failing. I am beginning to suspect that I have to pass in a fresh handle to the window...

I will give it another run through the debugger...

Share this post


Link to post
Share on other sites
Call ID3DXFont::OnLostDevice before reseting the device and ID3DXFont::OnResetDevice afterwards.

[edit] if that doesn't work then try to pass the handle of the window again, it won't hurt to try [smile]

Share this post


Link to post
Share on other sites
Well, it comes back up now without crashing, but there is no text. I think I will have to play around a little more with it. I hadn't even thought that the font thingy was causing the problem. I guess thats what happens when you forget to release and reinstate something...

EDIT - Still getting a bad result from the D3DDevice->Reset() though. I will give the window handle thingy a shot...

Share this post


Link to post
Share on other sites
Okay, I tried passing in a fresh handle to the window, but it didn't seem to do anything. The reason I suspect that my window handle is bad is because when I look at the local variables during debugging, the handle to the window has a value of something like:

HWND: 0x002f006c {unused=33723518}
unused: 33723518

That isn't right, is it?

Share this post


Link to post
Share on other sites
Okay, I think I might have discovered that I am doing something wrong. How do I determine that it is time to reset the device? Right now I am simply Sleep()ing for a bit, then trying to create the device again. This seems to be creating some interesting effects... (ie: my program doesn't like to be minimized, and keeps trying to bring itself back up). Should I be checking the windows messages for something? If that is the case, how do I pass the message along to my engine?

Share this post


Link to post
Share on other sites
It is "right", take a look and see that that "unused" stuff will always appear.. I don't really know how to explain this to you, I suppose it's because the debugger can't keep track of that stuff... I don't know.

I don't really remember for sure, but I think all renderstates are also reset when you reset the device, so you might want to check if you're forgeting to set your renderstates after reseting the device.

Share this post


Link to post
Share on other sites
Quote:
Original post by Moe
Okay, I think I might have discovered that I am doing something wrong. How do I determine that it is time to reset the device? Right now I am simply Sleep()ing for a bit, then trying to create the device again. This seems to be creating some interesting effects... (ie: my program doesn't like to be minimized, and keeps trying to bring itself back up). Should I be checking the windows messages for something? If that is the case, how do I pass the message along to my engine?


you'd check if a device needes reseting with the IDirect3DDevice9::TestCooperativeLevel() method.

Share this post


Link to post
Share on other sites
Should I be testing the cooperative level before calling Present() or should I simply call Present() and then check what is returned from it?

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!