1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

save and restore dc state

This commit is contained in:
FunkyFr3sh 2024-08-15 12:06:02 +02:00
parent 79feefac26
commit f49f09895b
3 changed files with 6 additions and 1 deletions

View File

@ -38,6 +38,7 @@ typedef struct IDirectDrawSurfaceImpl
PBITMAPINFO bmi;
HBITMAP bitmap;
HDC hdc;
int dc_state;
DDCOLORKEY color_key;
DWORD last_flip_tick;
DWORD last_blt_tick;

View File

@ -1283,7 +1283,7 @@ HRESULT dd_SetCooperativeLevel(HWND hwnd, DWORD dwFlags)
{
hook_init();
g_ddraw.wndproc = (WNDPROC)real_SetWindowLongA(g_ddraw.hwnd, GWL_WNDPROC, (LONG)fake_WndProc);
//g_ddraw.wndproc = (WNDPROC)real_SetWindowLongA(g_ddraw.hwnd, GWL_WNDPROC, (LONG)fake_WndProc);
g_ddraw.gui_thread_id = GetWindowThreadProcessId(g_ddraw.hwnd, NULL);
if (!g_ddraw.render.hdc)

View File

@ -914,6 +914,8 @@ HRESULT dds_GetDC(IDirectDrawSurfaceImpl* This, HDC FAR* lpHDC)
if (lpHDC)
*lpHDC = dc;
InterlockedExchange(&This->dc_state, SaveDC(dc));
return DD_OK;
}
@ -1024,6 +1026,8 @@ HRESULT dds_ReleaseDC(IDirectDrawSurfaceImpl* This, HDC hDC)
}
}
RestoreDC(hDC, InterlockedExchangeAdd((LONG*)&This->dc_state, 0));
return DD_OK;
}