A good method I''ve found is to use
TestCooperativeLevel method of the IDirect3DDevice8 interface...so JUST before you call
BeginScene in your rendering loop, you test the cooperative level...if you get back a D3DERR_DEVICEERR (or something like that..check the docs) then the user has alt+tabbed out of your program.
You''ll have to call
Reset to rest the device, then (depending on how you declared your vertex buffers), you''ll have to reload the vertex and texture information...
ie.
HRESULT beginRendering(){ HRESULT hr; hr = lpD3DDevice->TestCooperativeLevel(); if(FAILED(hr)) ( if(hr == D3DERR_DEVICEERR) { //reset the direct3d device, and reload the //textures lpD3DDevice->Reset(); hr = loadTextures(); if(FAILED(hr)) { return E_FAIL; } } } lpD3DDevice->Clear(..); return(lpD3DDevice->BeginScene());}
something like that..