Index: ddraw/glDirectDraw.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2018 William Feely
|
| 3 | +// Copyright (C) 2011-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -1311,6 +1311,11 @@ |
1312 | 1312 | if (lpDDSurfaceDesc2->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
1313 | 1313 | *lplpDDSurface = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0, version, NULL);
|
1314 | 1314 | }
|
| 1315 | + if (error != DD_OK)
|
| 1316 | + {
|
| 1317 | + delete (glDirectDrawSurface7*)*lplpDDSurface;
|
| 1318 | + *lplpDDSurface = NULL;
|
| 1319 | + }
|
1315 | 1320 | TRACE_VAR("*lplpDDSurface",14,*lplpDDSurface);
|
1316 | 1321 | TRACE_EXIT(23,error);
|
1317 | 1322 | return error;
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2016 William Feely
|
| 3 | +// Copyright (C) 2011-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -285,6 +285,13 @@ |
286 | 286 | ddsd.dwFlags |= DDSD_PIXELFORMAT;
|
287 | 287 | memcpy(&ddsd.ddpfPixelFormat, &texture->levels[this->miplevel].ddsd.ddpfPixelFormat, sizeof(DDPIXELFORMAT));
|
288 | 288 | }
|
| 289 | + if (!glTexture_ValidatePixelFormat(&ddsd.ddpfPixelFormat))
|
| 290 | + {
|
| 291 | + *error = DDERR_INVALIDPIXELFORMAT;
|
| 292 | + TRACE_VAR("*error", 23, DDERR_INVALIDPIXELFORMAT);
|
| 293 | + TRACE_EXIT(-1, 0);
|
| 294 | + return;
|
| 295 | + }
|
289 | 296 | if (ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
290 | 297 | {
|
291 | 298 | if (ddInterface->GetBPP() == 8)
|
Index: ddraw/glTexture.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2012-2016 William Feely
|
| 3 | +// Copyright (C) 2012-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -400,6 +400,23 @@ |
401 | 401 | if(This->dummycolor) glTexture_Release(This->dummycolor, backend);
|
402 | 402 | This->dummycolor = NULL;
|
403 | 403 | }
|
| 404 | +BOOL glTexture_ValidatePixelFormat(DDPIXELFORMAT *pixelformat)
|
| 405 | +{
|
| 406 | + int i;
|
| 407 | + int texformat = -1;
|
| 408 | + numtexformats = END_TEXFORMATS - START_TEXFORMATS;
|
| 409 | + for (i = 0; i < numtexformats; i++)
|
| 410 | + {
|
| 411 | + if (!memcmp(&texformats[i], pixelformat, sizeof(DDPIXELFORMAT)))
|
| 412 | + {
|
| 413 | + texformat = i;
|
| 414 | + break;
|
| 415 | + }
|
| 416 | + }
|
| 417 | + if (texformat == -1) return FALSE;
|
| 418 | + else return TRUE;
|
| 419 | +}
|
| 420 | +
|
404 | 421 | HRESULT glTexture__SetSurfaceDesc(glTexture *This, LPDDSURFACEDESC2 ddsd)
|
405 | 422 | {
|
406 | 423 | // FIXME: Implement SetSurfaceDesc fully
|
Index: ddraw/glTexture.h |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2012-2016 William Feely
|
| 3 | +// Copyright (C) 2012-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | void glTexture_SetStencil(glTexture *This, glTexture *stencil, BOOL backend);
|
45 | 45 | void glTexture_CreateDummyColor(glTexture *This, BOOL backend);
|
46 | 46 | void glTexture_DeleteDummyColor(glTexture *This, BOOL backend);
|
| 47 | +BOOL glTexture_ValidatePixelFormat(DDPIXELFORMAT *pixelformat);
|
47 | 48 | void glTexture__SetFilter(glTexture *This, int level, GLint mag, GLint min, struct glRenderer *renderer);
|
48 | 49 | HRESULT glTexture__SetSurfaceDesc(glTexture *This, LPDDSURFACEDESC2 ddsd);
|
49 | 50 | void glTexture__Download(glTexture *This, GLint level);
|
Index: dxglcfg/surfacegen.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2018 William Feely
|
| 3 | +// Copyright (C) 2011-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -1672,6 +1672,9 @@ |
1673 | 1673 | {
|
1674 | 1674 | _T("Primary surface"), // -1
|
1675 | 1675 | _T("Same as primary"), // 0
|
| 1676 | + _T("1-bit Palette"),
|
| 1677 | + _T("2-bit Palette"),
|
| 1678 | + _T("4-bit Palette"),
|
1676 | 1679 | _T("8-bit Palette"),
|
1677 | 1680 | _T("8-bit 332"),
|
1678 | 1681 | _T("15-bit 555"),
|
— | — | @@ -1700,6 +1703,9 @@ |
1701 | 1704 | const DDPIXELFORMAT surfaceformats[] =
|
1702 | 1705 | {
|
1703 | 1706 | {0, 0, 0, 0, 0, 0, 0, 0}, // reserved
|
| 1707 | + {sizeof(DDPIXELFORMAT), DDPF_PALETTEINDEXED1, 0, 1, 0, 0, 0, 0}, // 8-bit paletted
|
| 1708 | + {sizeof(DDPIXELFORMAT), DDPF_PALETTEINDEXED2, 0, 2, 0, 0, 0, 0}, // 8-bit paletted
|
| 1709 | + {sizeof(DDPIXELFORMAT), DDPF_PALETTEINDEXED4, 0, 4, 0, 0, 0, 0}, // 8-bit paletted
|
1704 | 1710 | {sizeof(DDPIXELFORMAT), DDPF_PALETTEINDEXED8, 0, 8, 0, 0, 0, 0}, // 8-bit paletted
|
1705 | 1711 | {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 8, 0xE0, 0x1C, 0x3, 0}, // 8 bit 332
|
1706 | 1712 | {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0x7C00, 0x3E0, 0x1F, 0}, // 15 bit 555
|