mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-25 10:07:47 +01:00
fixes resolution changes during run time with d3d9 and opengl renderers
This commit is contained in:
parent
202e4eb869
commit
5477e5139a
22
src/main.c
22
src/main.c
@ -285,8 +285,11 @@ HRESULT __stdcall ddraw_RestoreDisplayMode(IDirectDrawImpl *This)
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
LeaveCriticalSection(&This->cs);
|
||||
|
||||
if (This->render.thread)
|
||||
{
|
||||
WaitForSingleObject(This->render.thread, INFINITE);
|
||||
This->render.thread = NULL;
|
||||
}
|
||||
|
||||
if (This->renderer == render_d3d9_main)
|
||||
Direct3D9_Release();
|
||||
@ -316,6 +319,18 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
|
||||
{
|
||||
printf("DirectDraw::SetDisplayMode(This=%p, width=%d, height=%d, bpp=%d)\n", This, (unsigned int)width, (unsigned int)height, (unsigned int)bpp);
|
||||
|
||||
if (This->render.thread)
|
||||
{
|
||||
EnterCriticalSection(&This->cs);
|
||||
This->render.run = FALSE;
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
LeaveCriticalSection(&This->cs);
|
||||
|
||||
WaitForSingleObject(This->render.thread, INFINITE);
|
||||
This->render.thread = NULL;
|
||||
Sleep(500);
|
||||
}
|
||||
|
||||
if (!This->mode.dmPelsWidth)
|
||||
{
|
||||
This->mode.dmSize = sizeof(DEVMODE);
|
||||
@ -487,8 +502,6 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
|
||||
}
|
||||
|
||||
if (This->windowed)
|
||||
{
|
||||
if(!This->windowed_init)
|
||||
{
|
||||
if (!This->border)
|
||||
{
|
||||
@ -514,7 +527,6 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
|
||||
if (This->renderer == render_d3d9_main)
|
||||
InitDirect3D9();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (This->renderer == render_d3d9_main)
|
||||
@ -547,7 +559,6 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
|
||||
if(This->render.thread == NULL)
|
||||
{
|
||||
This->render.thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)This->renderer, NULL, 0, NULL);
|
||||
//SetThreadPriority(This->render.thread, THREAD_PRIORITY_BELOW_NORMAL);
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
@ -998,8 +1009,11 @@ ULONG __stdcall ddraw_Release(IDirectDrawImpl *This)
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
LeaveCriticalSection(&This->cs);
|
||||
|
||||
if (This->render.thread)
|
||||
{
|
||||
WaitForSingleObject(This->render.thread, INFINITE);
|
||||
This->render.thread = NULL;
|
||||
}
|
||||
|
||||
if (This->renderer == render_d3d9_main)
|
||||
Direct3D9_Release();
|
||||
|
@ -130,17 +130,13 @@ BOOL Direct3D9_Release()
|
||||
|
||||
if (D3dDev)
|
||||
{
|
||||
if (FAILED(D3dDev->lpVtbl->Release(D3dDev)))
|
||||
return FALSE;
|
||||
|
||||
D3dDev->lpVtbl->Release(D3dDev);
|
||||
D3dDev = NULL;
|
||||
}
|
||||
|
||||
if (D3d)
|
||||
{
|
||||
if (FAILED(D3d->lpVtbl->Release(D3d)))
|
||||
return FALSE;
|
||||
|
||||
D3d->lpVtbl->Release(D3d);
|
||||
D3d = NULL;
|
||||
}
|
||||
|
||||
|
@ -197,14 +197,12 @@ static void CreateSettingsIni()
|
||||
"sleep=10\n"
|
||||
"\n"
|
||||
"[EMPIRES2]\n"
|
||||
"renderer=gdi\n"
|
||||
"hidemouse=false\n"
|
||||
"border=false\n"
|
||||
"posX=0\n"
|
||||
"posY=0\n"
|
||||
"\n"
|
||||
"[age2_x1]\n"
|
||||
"renderer=gdi\n"
|
||||
"hidemouse=false\n"
|
||||
"border=false\n"
|
||||
"posX=0\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user