On my DirectX programs, everytime i alt-tab (in fullscreen), my desktop looks distorted and there are pieces of my program hanging about, and when i try to alt-tab back into the program, nothing happens.
So i found a tutorial on a site, and added a Lost Device handler (or whatever its called):
and heres the implementation in the Render Function:Code:bool ValidateDevice() { HRESULT hResult = NULL; hResult = g_Device->TestCooperativeLevel(); if (FAILED(hResult)) { if (hResult == D3DERR_DEVICELOST) return false; if (hResult == D3DERR_DEVICENOTRESET) { if (FAILED(g_Device->Reset(&g_PresentParameters))) { DestroyWindow(hWnd); return false; } } } return true; }
Using the ValidateDevice function, i can alt-tab out of my program fine, i dont see any 'visual defects', but when i try to alt-tab back into the program, it just exits by itself.Code:bool Render() { if (!ValidateDevice()) return false; g_Device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); g_Device->BeginScene(); //..... g_Device->EndScene(); g_Device->Present(NULL, NULL, NULL, NULL); return true; }
Theres little/no error handling, but im not worried about that for the time being.
PaYnE



LinkBack URL
About LinkBacks


