From: Michael Müller michael@fds-team.de
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=43638
Also fixes "Plebby Quest: The Crusades".
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/opengl32/tests/opengl.c | 59 +++++++++++++++++++++++------------- dlls/opengl32/wgl.c | 2 +- 2 files changed, 39 insertions(+), 22 deletions(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index c2fc4f4092..db5ad0ad76 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -220,7 +220,7 @@ static void test_pbuffers(HDC hdc) else skip("Pbuffer test for offscreen pixelformat skipped as no offscreen-only format with pbuffer capabilities has been found\n"); }
-static int test_pfd(const PIXELFORMATDESCRIPTOR *pfd) +static int test_pfd(const PIXELFORMATDESCRIPTOR *pfd, PIXELFORMATDESCRIPTOR *fmt) { int pf; HDC hdc; @@ -233,6 +233,12 @@ static int test_pfd(const PIXELFORMATDESCRIPTOR *pfd)
hdc = GetDC( hwnd ); pf = ChoosePixelFormat( hdc, pfd ); + if (pf && fmt) + { + memset(fmt, 0, sizeof(*fmt)); + ok(DescribePixelFormat( hdc, pf, sizeof(*fmt), fmt ), + "DescribePixelFormat failed with error: %u\n", GetLastError()); + } ReleaseDC( hwnd, hdc ); DestroyWindow( hwnd );
@@ -259,57 +265,68 @@ static void test_choosepixelformat(void) 0, /* reserved */ 0, 0, 0 /* layer masks */ }; + PIXELFORMATDESCRIPTOR ret_fmt;
- ok( test_pfd(&pfd), "Simple pfd failed\n" ); + ok( test_pfd(&pfd, NULL), "Simple pfd failed\n" ); pfd.dwFlags |= PFD_DOUBLEBUFFER_DONTCARE; - ok( test_pfd(&pfd), "PFD_DOUBLEBUFFER_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_DOUBLEBUFFER_DONTCARE failed\n" ); pfd.dwFlags |= PFD_STEREO_DONTCARE; - ok( test_pfd(&pfd), "PFD_DOUBLEBUFFER_DONTCARE|PFD_STEREO_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_DOUBLEBUFFER_DONTCARE|PFD_STEREO_DONTCARE failed\n" ); pfd.dwFlags &= ~PFD_DOUBLEBUFFER_DONTCARE; - ok( test_pfd(&pfd), "PFD_STEREO_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_STEREO_DONTCARE failed\n" ); pfd.dwFlags &= ~PFD_STEREO_DONTCARE; + pfd.iPixelType = 32; + ok( test_pfd(&pfd, &ret_fmt), "Invalid pixel format 32 failed\n" ); + ok( ret_fmt.iPixelType == PFD_TYPE_RGBA, "Expected pixel type PFD_TYPE_RGBA, got %d\n", ret_fmt.iPixelType ); + pfd.iPixelType = 33; + ok( test_pfd(&pfd, &ret_fmt), "Invalid pixel format 33 failed\n" ); + ok( ret_fmt.iPixelType == PFD_TYPE_RGBA, "Expected pixel type PFD_TYPE_RGBA, got %d\n", ret_fmt.iPixelType ); + pfd.iPixelType = 15; + ok( test_pfd(&pfd, &ret_fmt), "Invalid pixel format 15 failed\n" ); + ok( ret_fmt.iPixelType == PFD_TYPE_RGBA, "Expected pixel type PFD_TYPE_RGBA, got %d\n", ret_fmt.iPixelType ); + pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32; - ok( test_pfd(&pfd), "Simple pfd failed\n" ); + ok( test_pfd(&pfd, NULL), "Simple pfd failed\n" ); pfd.dwFlags |= PFD_DOUBLEBUFFER_DONTCARE; - ok( test_pfd(&pfd), "PFD_DOUBLEBUFFER_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_DOUBLEBUFFER_DONTCARE failed\n" ); pfd.dwFlags |= PFD_STEREO_DONTCARE; - ok( test_pfd(&pfd), "PFD_DOUBLEBUFFER_DONTCARE|PFD_STEREO_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_DOUBLEBUFFER_DONTCARE|PFD_STEREO_DONTCARE failed\n" ); pfd.dwFlags &= ~PFD_DOUBLEBUFFER_DONTCARE; - ok( test_pfd(&pfd), "PFD_STEREO_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_STEREO_DONTCARE failed\n" ); pfd.dwFlags &= ~PFD_STEREO_DONTCARE; pfd.cColorBits = 0;
pfd.cAlphaBits = 8; - ok( test_pfd(&pfd), "Simple pfd failed\n" ); + ok( test_pfd(&pfd, NULL), "Simple pfd failed\n" ); pfd.dwFlags |= PFD_DOUBLEBUFFER_DONTCARE; - ok( test_pfd(&pfd), "PFD_DOUBLEBUFFER_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_DOUBLEBUFFER_DONTCARE failed\n" ); pfd.dwFlags |= PFD_STEREO_DONTCARE; - ok( test_pfd(&pfd), "PFD_DOUBLEBUFFER_DONTCARE|PFD_STEREO_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_DOUBLEBUFFER_DONTCARE|PFD_STEREO_DONTCARE failed\n" ); pfd.dwFlags &= ~PFD_DOUBLEBUFFER_DONTCARE; - ok( test_pfd(&pfd), "PFD_STEREO_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_STEREO_DONTCARE failed\n" ); pfd.dwFlags &= ~PFD_STEREO_DONTCARE; pfd.cAlphaBits = 0;
pfd.cStencilBits = 8; - ok( test_pfd(&pfd), "Simple pfd failed\n" ); + ok( test_pfd(&pfd, NULL), "Simple pfd failed\n" ); pfd.dwFlags |= PFD_DOUBLEBUFFER_DONTCARE; - ok( test_pfd(&pfd), "PFD_DOUBLEBUFFER_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_DOUBLEBUFFER_DONTCARE failed\n" ); pfd.dwFlags |= PFD_STEREO_DONTCARE; - ok( test_pfd(&pfd), "PFD_DOUBLEBUFFER_DONTCARE|PFD_STEREO_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_DOUBLEBUFFER_DONTCARE|PFD_STEREO_DONTCARE failed\n" ); pfd.dwFlags &= ~PFD_DOUBLEBUFFER_DONTCARE; - ok( test_pfd(&pfd), "PFD_STEREO_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_STEREO_DONTCARE failed\n" ); pfd.dwFlags &= ~PFD_STEREO_DONTCARE; pfd.cStencilBits = 0;
pfd.cAuxBuffers = 1; - ok( test_pfd(&pfd), "Simple pfd failed\n" ); + ok( test_pfd(&pfd, NULL), "Simple pfd failed\n" ); pfd.dwFlags |= PFD_DOUBLEBUFFER_DONTCARE; - ok( test_pfd(&pfd), "PFD_DOUBLEBUFFER_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_DOUBLEBUFFER_DONTCARE failed\n" ); pfd.dwFlags |= PFD_STEREO_DONTCARE; - ok( test_pfd(&pfd), "PFD_DOUBLEBUFFER_DONTCARE|PFD_STEREO_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_DOUBLEBUFFER_DONTCARE|PFD_STEREO_DONTCARE failed\n" ); pfd.dwFlags &= ~PFD_DOUBLEBUFFER_DONTCARE; - ok( test_pfd(&pfd), "PFD_STEREO_DONTCARE failed\n" ); + ok( test_pfd(&pfd, NULL), "PFD_STEREO_DONTCARE failed\n" ); pfd.dwFlags &= ~PFD_STEREO_DONTCARE; pfd.cAuxBuffers = 0; } diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index c6018b0c7b..008778c532 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -475,7 +475,7 @@ INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd) { if (!wglDescribePixelFormat( hdc, i, sizeof(format), &format )) continue;
- if (ppfd->iPixelType != format.iPixelType) + if ((ppfd->iPixelType == PFD_TYPE_COLORINDEX) != (format.iPixelType == PFD_TYPE_COLORINDEX)) { TRACE( "pixel type mismatch for iPixelFormat=%d\n", i ); continue;