After doing an Alt-Tab out of a DX program while its running, and then trying to refocus back onto the window, DX likes to do some crazy things and some resources need to be reset.
The two I've learned this about so far are the ID3DXFont object and the camera; which need to be released/reset. The code I have for this looks like this:
Now, the problem I'm having is with my meshes. If I Alt-Tab out, then open the window back up, my program is telling me I'm still rendering 125 objects, but anything that WAS being rendered beforehand just isn't anymore.
Attempt = D3DDevice->TestCooperativeLevel();
if(Attempt == D3DERR_DEVICELOST)
else if(Attempt == D3DERR_DEVICENOTRESET)
Camera->Init(D3DDevice, (float)PP.BackBufferWidth, (float)PP.BackBufferHeight);
//Note, Position, Look, Up, and Right are initialised in the Class constructor to avoid them
//being reset each to their hard-coded values upon re-focussing.
void cCamera::Init(IDirect3DDevice9* D3DDevice, float ScreenWidth, float ScreenHeight)
float AspectRatio = (ScreenWidth / ScreenHeight);
D3DXMatrixLookAtLH(&matView, &Position, &Look, &Up);
D3DXMatrixPerspectiveFovLH(&matLens, D3DX_PI/4, AspectRatio, 1.0f, 2000.0f);
I'm assuming the problem lies somewhere in having to release/reset an object related to these meshes. But I don't really see anything too unique to my mesh class (it consists of a D3DDevice passed from my DX class, but I doubt it has anything to do with that since it's always pointing to the same thing).
So I guess I'm just wondering what exactly has to be reset in order to render these meshes again. Any help is appreciated.