gdkglcontext-win32.c: Fix running with Mesa drivers
Some GL drivers such as Mesa-D3D12 do not allow one to call SetPixelFormat() on a given HDC if one pixel format has been already set for it, so first check the HDC with GetPixelFormat() to see whether a pixel format has already been set with the HDC, and only attempt to acquire the pixel format if one has not been set. This will fix running with GL on Windows using the Mesa drivers.
This commit is contained in:
parent
e024a542b0
commit
1b1dee86a5
@ -855,19 +855,30 @@ _set_pixformat_for_hdc (HDC hdc,
|
|||||||
const gboolean need_alpha_bits,
|
const gboolean need_alpha_bits,
|
||||||
GdkWin32Display *display)
|
GdkWin32Display *display)
|
||||||
{
|
{
|
||||||
PIXELFORMATDESCRIPTOR pfd;
|
gboolean already_checked = TRUE;
|
||||||
gboolean set_pixel_format_result = FALSE;
|
*best_idx = GetPixelFormat (hdc);
|
||||||
|
|
||||||
/* one is only allowed to call SetPixelFormat(), and so ChoosePixelFormat()
|
/* one is only allowed to call SetPixelFormat(), and so ChoosePixelFormat()
|
||||||
* one single time per window HDC
|
* one single time per window HDC
|
||||||
*/
|
*/
|
||||||
*best_idx = _get_wgl_pfd (hdc, need_alpha_bits, &pfd, display);
|
if (*best_idx == 0)
|
||||||
if (*best_idx != 0)
|
{
|
||||||
set_pixel_format_result = SetPixelFormat (hdc, *best_idx, &pfd);
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
|
gboolean set_pixel_format_result = FALSE;
|
||||||
|
|
||||||
/* ChoosePixelFormat() or SetPixelFormat() failed, bail out */
|
GDK_NOTE (OPENGL, g_print ("requesting pixel format...\n"));
|
||||||
if (*best_idx == 0 || !set_pixel_format_result)
|
already_checked = FALSE;
|
||||||
return FALSE;
|
*best_idx = _get_wgl_pfd (hdc, need_alpha_bits, &pfd, display);
|
||||||
|
|
||||||
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user