From: Damjan Jovanovic damjan.jov@gmail.com
Java (1.3 at least) calls ChoosePixelFormat() with the PFD_SUPPORT_GDI flag set and expects the returned PIXELFORMATDESCRIPTOR to have that flag set. If it doesn't, an exception is thrown and it fails to initialize graphics. If no PIXELFORMATDESCRIPTOR is returned instead, it falls back to an alternative rendering method and proceeds further.
Therefore, when the PFD_SUPPORT_GDI flag is specified, treat it as a mandatory requirement, and only return a PIXELFORMATDESCRIPTOR on which it is set, if any.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=7767 --- dlls/opengl32/tests/opengl.c | 2 +- dlls/opengl32/wgl.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index 3c3e96c4b8e..0a264dc6773 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -277,7 +277,7 @@ static void test_choosepixelformat(void) ok( test_pfd(&pfd, NULL), "PFD_STEREO_DONTCARE failed\n" ); pfd.dwFlags &= ~PFD_STEREO_DONTCARE; pfd.dwFlags |= PFD_SUPPORT_GDI; - todo_wine ok( test_pfd(&pfd, &ret_fmt) == 0 || (ret_fmt.dwFlags & PFD_SUPPORT_GDI), "PFD_SUPPORT_GDI requested but not returned\n"); + ok( test_pfd(&pfd, &ret_fmt) == 0 || (ret_fmt.dwFlags & PFD_SUPPORT_GDI), "PFD_SUPPORT_GDI requested but not returned\n"); pfd.dwFlags &= ~PFD_SUPPORT_GDI; pfd.iPixelType = 32; ok( test_pfd(&pfd, &ret_fmt), "Invalid pixel format 32 failed\n" ); diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index f57f7703409..888cb0fd22c 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -152,6 +152,12 @@ INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd) continue; }
+ if ((ppfd->dwFlags & PFD_SUPPORT_GDI) && !(format.dwFlags & PFD_SUPPORT_GDI)) + { + TRACE( "PFD_SUPPORT_GDI required but not found for iPixelFormat=%d\n", i ); + continue; + } + /* The behavior of PDF_STEREO/PFD_STEREO_DONTCARE and PFD_DOUBLEBUFFER / PFD_DOUBLEBUFFER_DONTCARE * is not very clear on MSDN. They specify that ChoosePixelFormat tries to match pixel formats * with the flag (PFD_STEREO / PFD_DOUBLEBUFFERING) set. Otherwise it says that it tries to match