diff --git a/gdk/win32/gdkdisplay-win32.h b/gdk/win32/gdkdisplay-win32.h index 1eca5f4317..0e6be8dd69 100644 --- a/gdk/win32/gdkdisplay-win32.h +++ b/gdk/win32/gdkdisplay-win32.h @@ -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; diff --git a/gdk/win32/gdkglcontext-win32-wgl.c b/gdk/win32/gdkglcontext-win32-wgl.c index 34fcca5677..e12604f3f5 100644 --- a/gdk/win32/gdkglcontext-win32-wgl.c +++ b/gdk/win32/gdkglcontext-win32-wgl.c @@ -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,