HRESULT WINAPI CDirect3DHook::hkEndScene(LPDIRECT3DDEVICE9 pDevice) { __asm pushad; g_pDevice = pDevice; //HRESULT cooperativeStatus = g_pDevice->TestCooperativeLevel(); //if(cooperativeStatus == D3DERR_DEVICENOTRESET) //{ // CLogFile::Printf("PreD3DReset"); // Direct3DInvalidate(); // i.e. pFont->OnLostDevice(); // bReset = true; //} //else if(cooperativeStatus == D3D_OK && bReset) //{ // CLogFile::Printf("PostD3DReset(1)"); // Direct3DReset(); // i.e. pFont->OnResetDevice(); // bReset = false; //} if(m_bInitialized == false) { HWND hFocusWindow = FindWindow(NULL,"GTAIV"); if(hFocusWindow != NULL) { SetWindowText(hFocusWindow, MOD_NAME DEBUG_IDENTIFIER); // Disable minimize & maximize box SetWindowLong(hFocusWindow, GWL_STYLE, GetWindowLong(hFocusWindow, GWL_STYLE) & ~WS_MINIMIZEBOX & ~WS_MAXIMIZEBOX); if(!m_wWndProc) { CLogFile::Printf("SubclassWindow"); m_wWndProc = SubclassWindow(hFocusWindow, WndProc_Hook); Direct3DInvalidate(); Direct3DReset(); m_bInitialized = true; } } } if(!bReset) Direct3DRender(); __asm popad; return m_pEndScene(g_pDevice); }
HRESULT WINAPI CDirect3DHook::hkReset(LPDIRECT3DDEVICE9 pDevice,D3DPRESENT_PARAMETERS* pPresentationParameters) { __asm pushad; if(g_pDevice == NULL) g_pDevice = pDevice; CLogFile::Printf("PreD3DReset"); // Call our lost device function Direct3DInvalidate(); if(g_bWindowedMode) { pPresentationParameters->Windowed = 1; pPresentationParameters->Flags = 0; pPresentationParameters->FullScreen_RefreshRateInHz = 0; pPresentationParameters->PresentationInterval = 0; LONG_PTR style = GetWindowLongPtr(pPresentationParameters->hDeviceWindow, GWL_STYLE); SetWindowLongPtr(pPresentationParameters->hDeviceWindow, GWL_STYLE, style | WS_POPUPWINDOW | WS_CAPTION | WS_THICKFRAME); SetWindowPos(pPresentationParameters->hDeviceWindow, HWND_NOTOPMOST, 0, 0, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight, SWP_SHOWWINDOW); } HRESULT hr = m_pReset(g_pDevice, pPresentationParameters); if(SUCCEEDED(hr)) { // Call our reset device function Direct3DReset(); CLogFile::Printf("PostD3DReset(1)"); } else { CLogFile::Printf("PostD3DReset(0)"); } __asm popad; return hr; }
static int ControlResetDevice(vout_display_t *vd) { return Direct3DReset(vd); }