Merge branch 'mesa.win32.fixes' into 'master'

gdkglcontext-win32.c: Fix running with Mesa drivers

See merge request GNOME/gtk!3483
This commit is contained in:
Matthias Clasen 2021-05-02 22:42:35 +00:00
commit 945b32ca1b

View File

@ -712,20 +712,30 @@ _set_pixformat_for_hdc (HDC hdc,
int *best_idx,
GdkWin32Display *display)
{
PIXELFORMATDESCRIPTOR pfd;
gboolean set_pixel_format_result = FALSE;
gboolean already_checked = TRUE;
*best_idx = GetPixelFormat (hdc);
/* one is only allowed to call SetPixelFormat(), and so ChoosePixelFormat()
* one single time per window HDC
*/
*best_idx = _get_wgl_pfd (hdc, &pfd, display);
if (*best_idx == 0)
{
PIXELFORMATDESCRIPTOR pfd;
gboolean set_pixel_format_result = FALSE;
if (*best_idx != 0)
set_pixel_format_result = SetPixelFormat (hdc, *best_idx, &pfd);
GDK_NOTE (OPENGL, g_print ("requesting pixel format...\n"));
already_checked = FALSE;
*best_idx = _get_wgl_pfd (hdc, &pfd, display);
/* ChoosePixelFormat() or SetPixelFormat() failed, bail out */
if (*best_idx == 0 || !set_pixel_format_result)
return FALSE;
if (*best_idx != 0)
set_pixel_format_result = SetPixelFormat (hdc, *best_idx, &pfd);
/* ChoosePixelFormat() or SetPixelFormat() failed, bail out */
if (*best_idx == 0 || !set_pixel_format_result)
return FALSE;
}
GDK_NOTE (OPENGL, g_print ("%s""requested and set pixel format: %d\n", already_checked ? "already " : "", *best_idx));
return TRUE;
}