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

add support for DDSD_LPSURFACE and DDSD_PITCH

This commit is contained in:
FunkyFr3sh 2022-09-15 10:10:52 +02:00
parent f39e3fcddb
commit edf69fcc2a
3 changed files with 11 additions and 3 deletions

View File

@ -30,6 +30,7 @@ typedef struct IDirectDrawSurfaceImpl
void* surface;
DWORD l_pitch;
DWORD lx_pitch;
BOOL custom_surface;
PBITMAPINFO bmi;
HBITMAP bitmap;

View File

@ -85,7 +85,7 @@ ULONG __stdcall IDirectDrawSurface__Release(IDirectDrawSurfaceImpl* This)
{
DeleteObject(This->bitmap);
}
else if (This->surface)
else if (This->surface && !This->custom_surface)
{
HeapFree(GetProcessHeap(), 0, This->surface);
}

View File

@ -596,7 +596,6 @@ HRESULT dds_GetAttachedSurface(IDirectDrawSurfaceImpl* This, LPDDSCAPS lpDdsCaps
IDirectDrawSurface_AddRef(This);
*lpDDsurface = This;
}
}
return DD_OK;
}
@ -1037,7 +1036,15 @@ HRESULT dd_CreateSurface(
dst_surface->height = lpDDSurfaceDesc->dwHeight;
}
if (dst_surface->width && dst_surface->height)
if ((dst_surface->flags & DDSD_LPSURFACE) && (dst_surface->flags & DDSD_PITCH))
{
dst_surface->surface = lpDDSurfaceDesc->lpSurface;
dst_surface->l_pitch = lpDDSurfaceDesc->lPitch;
dst_surface->lx_pitch = dst_surface->bpp / 8;
dst_surface->size = dst_surface->l_pitch * dst_surface->height;
dst_surface->custom_surface = TRUE;
}
else if (dst_surface->width && dst_surface->height)
{
dst_surface->lx_pitch = dst_surface->bpp / 8;
dst_surface->l_pitch = ((dst_surface->width * dst_surface->bpp + 31) & ~31) >> 3;