1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-24 17:49:52 +01:00

some experimental code for Capitalism2/CapLab

This commit is contained in:
FunkyFr3sh 2021-05-06 00:15:47 +02:00
parent d7ad443d92
commit 442b6c3f57

View File

@ -15,6 +15,15 @@
HRESULT dds_AddAttachedSurface(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWSURFACE lpDDSurface) HRESULT dds_AddAttachedSurface(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWSURFACE lpDDSurface)
{ {
IDirectDrawSurface_AddRef(lpDDSurface); IDirectDrawSurface_AddRef(lpDDSurface);
if (g_ddraw->backbuffer && !This->backbuffer)
{
IDirectDrawSurfaceImpl* surface = (IDirectDrawSurfaceImpl*)lpDDSurface;
surface->caps |= DDSCAPS_BACKBUFFER;
This->backbuffer = surface;
}
return DD_OK; return DD_OK;
} }
@ -672,21 +681,21 @@ HRESULT dds_EnumAttachedSurfaces(IDirectDrawSurfaceImpl *This, LPVOID lpContext,
HRESULT dds_Flip(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWSURFACE surface, DWORD flags) HRESULT dds_Flip(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWSURFACE surface, DWORD flags)
{ {
if(This->caps & DDSCAPS_PRIMARYSURFACE && g_ddraw->render.run) if (This->backbuffer)
{ {
if (This->backbuffer) EnterCriticalSection(&g_ddraw->cs);
{ void* surface = InterlockedExchangePointer(&This->surface, This->backbuffer->surface);
EnterCriticalSection(&g_ddraw->cs); HBITMAP bitmap = (HBITMAP)InterlockedExchangePointer(&This->bitmap, This->backbuffer->bitmap);
void* surface = InterlockedExchangePointer(&This->surface, This->backbuffer->surface); HDC hdc = (HDC)InterlockedExchangePointer(&This->hdc, This->backbuffer->hdc);
HBITMAP bitmap = (HBITMAP)InterlockedExchangePointer(&This->bitmap, This->backbuffer->bitmap);
HDC hdc = (HDC)InterlockedExchangePointer(&This->hdc, This->backbuffer->hdc);
InterlockedExchangePointer(&This->backbuffer->surface, surface); InterlockedExchangePointer(&This->backbuffer->surface, surface);
InterlockedExchangePointer(&This->backbuffer->bitmap, bitmap); InterlockedExchangePointer(&This->backbuffer->bitmap, bitmap);
InterlockedExchangePointer(&This->backbuffer->hdc, hdc); InterlockedExchangePointer(&This->backbuffer->hdc, hdc);
LeaveCriticalSection(&g_ddraw->cs); LeaveCriticalSection(&g_ddraw->cs);
} }
if (This->caps & DDSCAPS_PRIMARYSURFACE && g_ddraw->render.run)
{
This->last_flip_tick = timeGetTime(); This->last_flip_tick = timeGetTime();
InterlockedExchange(&g_ddraw->render.surface_updated, TRUE); InterlockedExchange(&g_ddraw->render.surface_updated, TRUE);