mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
Move critical section to main ddraw, fix shadow window bug when exiting fullscreen
This commit is contained in:
parent
40f196bc8f
commit
fdf8395dd1
21
main.c
21
main.c
@ -139,21 +139,25 @@ HRESULT __stdcall ddraw_Initialize(IDirectDrawImpl *This, GUID *a)
|
||||
HRESULT __stdcall ddraw_RestoreDisplayMode(IDirectDrawImpl *This)
|
||||
{
|
||||
printf("DirectDraw::RestoreDisplayMode(This=%p)\n", This);
|
||||
|
||||
if(!This->render.run)
|
||||
{
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&This->cs);
|
||||
This->render.run = FALSE;
|
||||
LeaveCriticalSection(&This->cs);
|
||||
|
||||
WaitForSingleObject(This->render.thread, INFINITE);
|
||||
This->render.thread = NULL;
|
||||
|
||||
if(!ddraw->windowed)
|
||||
{
|
||||
This->mode.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFLAGS|DM_DISPLAYFREQUENCY|DM_POSITION;
|
||||
ChangeDisplaySettings(&This->mode, 0);
|
||||
}
|
||||
|
||||
This->render.run = FALSE;
|
||||
WaitForSingleObject(This->render.thread, INFINITE);
|
||||
This->render.thread = NULL;
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
@ -165,6 +169,7 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
|
||||
{
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
This->render.run = TRUE;
|
||||
|
||||
/* currently we only support 8 bit modes */
|
||||
@ -429,11 +434,17 @@ ULONG __stdcall ddraw_Release(IDirectDrawImpl *This)
|
||||
{
|
||||
if(This->render.run)
|
||||
{
|
||||
EnterCriticalSection(&This->cs);
|
||||
|
||||
This->render.run = FALSE;
|
||||
WaitForSingleObject(This->render.thread, INFINITE);
|
||||
This->render.thread = NULL;
|
||||
|
||||
LeaveCriticalSection(&This->cs);
|
||||
}
|
||||
|
||||
DeleteCriticalSection(&This->cs);
|
||||
|
||||
/* restore old wndproc, subsequent ddraw creation will otherwise fail */
|
||||
SetWindowLong(This->hWnd, GWL_WNDPROC, (LONG)This->WndProc);
|
||||
//free(This);
|
||||
@ -520,6 +531,8 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
|
||||
InitializeCriticalSection(&This->cs);
|
||||
|
||||
/* load configuration options from ddraw.ini */
|
||||
char cwd[MAX_PATH];
|
||||
char ini_path[MAX_PATH];
|
||||
|
2
main.h
2
main.h
@ -44,6 +44,7 @@ typedef struct IDirectDrawImpl
|
||||
|
||||
/* real export from system32\ddraw.dll */
|
||||
HRESULT WINAPI (*DirectDrawCreate)(GUID FAR*, LPDIRECTDRAW FAR*, IUnknown FAR*);
|
||||
CRITICAL_SECTION cs;
|
||||
|
||||
struct
|
||||
{
|
||||
@ -56,7 +57,6 @@ typedef struct IDirectDrawImpl
|
||||
HANDLE thread;
|
||||
BOOL run;
|
||||
HANDLE ev;
|
||||
CRITICAL_SECTION cs;
|
||||
DEVMODE mode;
|
||||
|
||||
} render;
|
||||
|
6
render.c
6
render.c
@ -62,7 +62,6 @@ DWORD WINAPI render_main(void)
|
||||
}
|
||||
|
||||
ddraw->render.ev = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
InitializeCriticalSection(&ddraw->render.cs);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tex_width, tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex);
|
||||
glViewport(0, 0, ddraw->render.width, ddraw->render.height);
|
||||
@ -93,7 +92,7 @@ DWORD WINAPI render_main(void)
|
||||
}
|
||||
|
||||
/* convert ddraw surface to opengl texture */
|
||||
EnterCriticalSection(&ddraw->render.cs);
|
||||
EnterCriticalSection(&ddraw->cs);
|
||||
if(ddraw->primary && ddraw->primary->palette)
|
||||
{
|
||||
for(i=0; i<ddraw->height; i++)
|
||||
@ -104,7 +103,7 @@ DWORD WINAPI render_main(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
LeaveCriticalSection(&ddraw->render.cs);
|
||||
LeaveCriticalSection(&ddraw->cs);
|
||||
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ddraw->width, ddraw->height, GL_RGBA, GL_UNSIGNED_BYTE, tex);
|
||||
|
||||
@ -130,7 +129,6 @@ DWORD WINAPI render_main(void)
|
||||
SetEvent(ddraw->render.ev);
|
||||
}
|
||||
|
||||
DeleteCriticalSection(&ddraw->render.cs);
|
||||
CloseHandle(ddraw->render.ev);
|
||||
ddraw->render.ev = NULL;
|
||||
|
||||
|
13
surface.c
13
surface.c
@ -46,16 +46,9 @@ ULONG __stdcall ddraw_surface_Release(IDirectDrawSurfaceImpl *This)
|
||||
{
|
||||
if(This->caps == DDSCAPS_PRIMARYSURFACE)
|
||||
{
|
||||
if(ddraw->render.run)
|
||||
{
|
||||
EnterCriticalSection(&ddraw->render.cs);
|
||||
ddraw->primary = NULL;
|
||||
LeaveCriticalSection(&ddraw->render.cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
ddraw->primary = NULL;
|
||||
}
|
||||
EnterCriticalSection(&ddraw->cs);
|
||||
ddraw->primary = NULL;
|
||||
LeaveCriticalSection(&ddraw->cs);
|
||||
}
|
||||
if(This->surface)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user