Merge branch 'issue-6401-legacy' into 'main'

Win32 GL: Also force not to use depth/stencil/accum bits on legacy contexts (for issue #6401)

See merge request GNOME/gtk!7176
This commit is contained in:
Matthias Clasen
2024-05-29 23:18:04 +00:00
2 changed files with 21 additions and 6 deletions

View File

@@ -134,6 +134,7 @@ struct _GdkWin32Display
guint hasWglEXTSwapControl : 1;
guint hasWglOMLSyncControl : 1;
guint hasWglARBPixelFormat : 1;
guint force_enable_depth_bits : 1;
#ifdef HAVE_EGL
guint hasEglKHRCreateContext : 1;

View File

@@ -142,8 +142,7 @@ get_wgl_pfd (HDC hdc,
pfd->nSize = sizeof (PIXELFORMATDESCRIPTOR);
if (display_win32 != NULL &&
display_win32->hasWglARBPixelFormat)
if (display_win32->hasWglARBPixelFormat)
{
UINT num_formats;
int colorbits = GetDeviceCaps (hdc, BITSPIXEL);
@@ -176,15 +175,18 @@ get_wgl_pfd (HDC hdc,
pixelAttribs[i++] = WGL_ALPHA_BITS_ARB;
pixelAttribs[i++] = 8;
pixelAttribs[i++] = WGL_DEPTH_BITS_ARB;
pixelAttribs[i++] = 0;
pixelAttribs[i++] = WGL_STENCIL_BITS_ARB;
pixelAttribs[i++] = 0;
pixelAttribs[i++] = WGL_ACCUM_BITS_ARB;
pixelAttribs[i++] = 0;
if (!display_win32->force_enable_depth_bits)
{
pixelAttribs[i++] = WGL_DEPTH_BITS_ARB;
pixelAttribs[i++] = 0;
}
/* end of "Update PIXEL_ATTRIBUTES above if any groups are added here!" */
pixelAttribs[i++] = 0; /* end of pixelAttribs */
@@ -215,8 +217,20 @@ get_wgl_pfd (HDC hdc,
pfd->cColorBits = GetDeviceCaps (hdc, BITSPIXEL);
pfd->cAlphaBits = 8;
pfd->iLayerType = PFD_MAIN_PLANE;
pfd->cAccumBits = 0;
pfd->cStencilBits = 0;
if (!display_win32->force_enable_depth_bits)
pfd->cDepthBits = 0;
best_pf = ChoosePixelFormat (hdc, pfd);
/* try again if driver enforces depth buffers */
if (best_pf == 0 && !display_win32->force_enable_depth_bits)
{
display_win32->force_enable_depth_bits = TRUE;
get_wgl_pfd (hdc, pfd, display_win32);
}
}
return best_pf;
@@ -234,7 +248,7 @@ gdk_init_dummy_wgl_context (GdkWin32Display *display_win32)
memset (&pfd, 0, sizeof (PIXELFORMATDESCRIPTOR));
best_idx = get_wgl_pfd (display_win32->dummy_context_wgl.hdc, &pfd, NULL);
best_idx = get_wgl_pfd (display_win32->dummy_context_wgl.hdc, &pfd, display_win32);
if (best_idx != 0)
set_pixel_format_result = SetPixelFormat (display_win32->dummy_context_wgl.hdc,