From: Rémi Bernon rbernon@codeweavers.com
http://bugs.winehq.org/show_bug.cgi?id=58402 --- dlls/opengl32/wgl.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index e24327af15b..b24225684e0 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -125,6 +125,7 @@ INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd) PIXELFORMATDESCRIPTOR format, best; int i, count, best_format; int bestDBuffer = -1, bestStereo = -1; + DWORD is_memdc;
TRACE( "%p %p: size %u version %u flags %lu type %u color %u %u,%u,%u,%u " "accum %u depth %u stencil %u aux %u\n", @@ -135,6 +136,8 @@ INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd) count = wglDescribePixelFormat( hdc, 0, 0, NULL ); if (!count) return 0;
+ if (!NtGdiGetDCDword( hdc, NtGdiIsMemDC, &is_memdc )) is_memdc = 0; + best_format = 0; best.dwFlags = 0; best.cAlphaBits = -1; @@ -174,6 +177,11 @@ INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd) TRACE( "PFD_SUPPORT_OPENGL required but not found for iPixelFormat=%d\n", i ); continue; } + if (is_memdc && ppfd->cColorBits == 16 && ppfd->cAlphaBits != 1) + { + TRACE( "Ignoring iPixelFormat=%d RGB565 format on memory DC\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 @@ -709,10 +717,13 @@ BOOL WINAPI wglChoosePixelFormatARB( HDC hdc, const int *attribs_int, const FLOA UINT i, num_wgl_formats, num_wgl_onscreen_formats; const struct wgl_pixel_format **format_array; struct compare_formats_ctx ctx = { 0 }; + DWORD is_memdc;
TRACE( "hdc %p, attribs_int %p, attribs_float %p, max_formats %u, formats %p, num_formats %p\n", hdc, attribs_int, attribs_float, max_formats, formats, num_formats );
+ if (!NtGdiGetDCDword( hdc, NtGdiIsMemDC, &is_memdc )) is_memdc = 0; + wgl_formats = get_pixel_formats( hdc, &num_wgl_formats, &num_wgl_onscreen_formats );
/* If the driver doesn't yet provide ARB attrib information in @@ -752,7 +763,12 @@ BOOL WINAPI wglChoosePixelFormatARB( HDC hdc, const int *attribs_int, const FLOA /* Initialize the format_array with (pointers to) all wgl formats */ format_array = malloc( num_wgl_formats * sizeof(*format_array) ); if (!format_array) return FALSE; - for (i = 0; i < num_wgl_formats; ++i) format_array[i] = &wgl_formats[i]; + for (i = 0; i < num_wgl_formats; ++i) + { + struct wgl_pixel_format *format = wgl_formats + i; + if (is_memdc && format->pfd.cColorBits == 16 && format->pfd.cAlphaBits != 1) format_array[i] = NULL; + else format_array[i] = &wgl_formats[i]; + }
/* Remove formats that are not acceptable */ for (i = 0; i < ctx.num_attribs; ++i)