mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Added DDSCAPS_OFFSCREENPLAIN to surfaces with no type capability
When a surface is created without an explicit capability to specify the type of surface to create, it only accepts a pixel format that matches the current display mode. Since the display mode is forced to 32 bit color depth under DDrawCompat, creating such surfaces could either fail if a different pixel format is specified (even though it could match the emulated color depth), or it could be created with the wrong color depth if no pixel format is given. To prevent these issues, the DDSCAPS_OFFSCREENPLAIN capability is added to all "untyped" surfaces, which accepts any color depth and already has code in place to match the emulated display mode's color depth when no pixel format is given. Fixes #1
This commit is contained in:
parent
8694b9a42b
commit
ee83a95c52
@ -117,18 +117,27 @@ HRESULT STDMETHODCALLTYPE CompatDirectDraw<TDirectDraw>::CreateSurface(
|
||||
else
|
||||
{
|
||||
if (lpDDSurfaceDesc &&
|
||||
!(lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT) &&
|
||||
(lpDDSurfaceDesc->dwFlags & DDSD_WIDTH) &&
|
||||
(lpDDSurfaceDesc->dwFlags & DDSD_HEIGHT) &&
|
||||
!((lpDDSurfaceDesc->dwFlags & DDSD_CAPS) &&
|
||||
(lpDDSurfaceDesc->ddsCaps.dwCaps & (DDSCAPS_ALPHA | DDSCAPS_ZBUFFER))))
|
||||
(lpDDSurfaceDesc->ddsCaps.dwCaps & (DDSCAPS_ALPHA | DDSCAPS_ZBUFFER))))
|
||||
{
|
||||
CompatPtr<IDirectDraw7> dd(Compat::queryInterface<IDirectDraw7>(This));
|
||||
auto dm = CompatDisplayMode::getDisplayMode(*dd);
|
||||
|
||||
TSurfaceDesc desc = *lpDDSurfaceDesc;
|
||||
desc.dwFlags |= DDSD_PIXELFORMAT;
|
||||
desc.ddpfPixelFormat = dm.pixelFormat;
|
||||
if (!(desc.dwFlags & DDSD_PIXELFORMAT))
|
||||
{
|
||||
desc.dwFlags |= DDSD_PIXELFORMAT;
|
||||
desc.ddpfPixelFormat = dm.pixelFormat;
|
||||
}
|
||||
if (!((desc.dwFlags & DDSD_CAPS) &&
|
||||
(desc.ddsCaps.dwCaps & (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_OVERLAY | DDSCAPS_TEXTURE |
|
||||
DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER))))
|
||||
{
|
||||
desc.dwFlags |= DDSD_CAPS;
|
||||
desc.ddsCaps.dwCaps |= DDSCAPS_OFFSCREENPLAIN;
|
||||
}
|
||||
result = s_origVtable.CreateSurface(This, &desc, lplpDDSurface, pUnkOuter);
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user