Use a semaphore object to synchronize rendering thread with the game
This commit is contained in:
parent
5192ebc44f
commit
a40282013b
6 changed files with 20 additions and 8 deletions
18
surface.c
18
surface.c
|
@ -93,12 +93,6 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR
|
|||
}
|
||||
#endif
|
||||
|
||||
if(This->caps & DDSCAPS_PRIMARYSURFACE && ddraw->render.run)
|
||||
{
|
||||
WaitForSingleObject(ddraw->render.ev, INFINITE);
|
||||
ResetEvent(ddraw->render.ev);
|
||||
}
|
||||
|
||||
if(Source)
|
||||
{
|
||||
int dx=0,dy=0;
|
||||
|
@ -126,6 +120,13 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR
|
|||
}
|
||||
}
|
||||
|
||||
if(This->caps & DDSCAPS_PRIMARYSURFACE && ddraw->render.run)
|
||||
{
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
WaitForSingleObject(ddraw->render.ev, INFINITE);
|
||||
ResetEvent(ddraw->render.ev);
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
|
@ -334,6 +335,11 @@ HRESULT __stdcall ddraw_surface_Unlock(IDirectDrawSurfaceImpl *This, LPVOID lpRe
|
|||
printf("DirectDrawSurface::Unlock(This=%p, lpRect=%p)\n", This, lpRect);
|
||||
#endif
|
||||
|
||||
if(This->caps & DDSCAPS_PRIMARYSURFACE && ddraw->render.run)
|
||||
{
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue