From 6a31983779479b42e0c2e5320a1dfa962767c28e Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Mon, 13 May 2024 20:15:30 -0600 Subject: [PATCH] opengl32: Prefer formats with depth if unspecified in wglChoosePixelFormat(). --- dlls/opengl32/tests/opengl.c | 1 + dlls/opengl32/wgl.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index 070229254a1..25485841d70 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -326,6 +326,7 @@ static void test_choosepixelformat(void) ok( ret_fmt.cAlphaShift == 24, "Got %u.\n", ret_fmt.cAlphaShift ); else ok( !ret_fmt.cAlphaShift, "Got %u.\n", ret_fmt.cAlphaShift ); + ok( ret_fmt.cDepthBits, "Got %u.\n", ret_fmt.cDepthBits ); pfd.dwFlags |= PFD_DOUBLEBUFFER_DONTCARE; ok( test_pfd(&pfd, NULL), "PFD_DOUBLEBUFFER_DONTCARE failed\n" ); diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 87f91aef473..9d2ce4ea215 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -284,7 +284,14 @@ INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd) continue; } } - if (ppfd->dwFlags & PFD_DEPTH_DONTCARE && format.cDepthBits < best.cDepthBits) + if (ppfd->dwFlags & PFD_DEPTH_DONTCARE) + { + if (format.cDepthBits < best.cDepthBits) + goto found; + continue; + } + + if (!ppfd->cDepthBits && format.cDepthBits > best.cDepthBits) goto found; continue;