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

Started by
12 comments, last by Moe 18 years, 8 months ago
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).
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.
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...
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]
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...
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?
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?
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.
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.
Should I be testing the cooperative level before calling Present() or should I simply call Present() and then check what is returned from it?

This topic is closed to new replies.

Advertisement