[gtk/wip.win32.fixes: 8/19] GDK-Win32: Reject WGL context if shaders aren't supported
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip.win32.fixes: 8/19] GDK-Win32: Reject WGL context if shaders aren't supported
- Date: Tue, 17 Aug 2021 08:27:57 +0000 (UTC)
commit 206a1101bd58c32ce911ebb48dfd6501e368211b
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue Aug 17 15:13:38 2021 +0800
GDK-Win32: Reject WGL context if shaders aren't supported
When we initialize OpenGL, check whether we have OpenGL 2.0 or later; if not,
check whether we have the 'GL_ARB_shader_objects' extension, since we must be
able to support shaders if using OpenGL for GTK.
If we don't support shaders, as some Windows graphics drivers do not support
OpenGL adequately, notably older Intel drivers, reject and destroy the GL
context that we created, and so fallback to the Cairo GSK renderer, so that
things continue to run, albeit with an expected warning message that the GL
context cannot be realized.
Fixes issue #4165.
gdk/win32/gdkglcontext-win32-egl.c | 2 +-
gdk/win32/gdkglcontext-win32-wgl.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/gdk/win32/gdkglcontext-win32-egl.c b/gdk/win32/gdkglcontext-win32-egl.c
index 9d2df6b499..cfc4417a9a 100644
--- a/gdk/win32/gdkglcontext-win32-egl.c
+++ b/gdk/win32/gdkglcontext-win32-egl.c
@@ -277,7 +277,7 @@ gdk_win32_display_init_egl (GdkDisplay *display,
display_win32->egl_disp = egl_disp;
display_win32->egl_version = epoxy_egl_version (egl_disp);
- eglBindAPI(EGL_OPENGL_ES_API);
+ eglBindAPI (EGL_OPENGL_ES_API);
display_win32->hasEglSurfacelessContext =
epoxy_has_egl_extension (egl_disp, "EGL_KHR_surfaceless_context");
diff --git a/gdk/win32/gdkglcontext-win32-wgl.c b/gdk/win32/gdkglcontext-win32-wgl.c
index 4b000f4792..3d05fb8907 100644
--- a/gdk/win32/gdkglcontext-win32-wgl.c
+++ b/gdk/win32/gdkglcontext-win32-wgl.c
@@ -278,6 +278,9 @@ gdk_win32_display_init_wgl (GdkDisplay *display,
if (best_idx == 0 ||
!wglMakeCurrent (hdc, display_win32->dummy_context_wgl.hglrc))
{
+ if (display_win32->dummy_context_wgl.hglrc != NULL)
+ wglDeleteContext (display_win32->dummy_context_wgl.hglrc);
+
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
_("No GL implementation is available"));
@@ -288,6 +291,22 @@ gdk_win32_display_init_wgl (GdkDisplay *display,
display_win32->wgl_pixel_format = best_idx;
display_win32->gl_version = epoxy_gl_version ();
+ /* We must have OpenGL/WGL 2.0 or later, or have the GL_ARB_shader_objects extension */
+ if (display_win32->gl_version < 20)
+ {
+ if (!epoxy_has_gl_extension ("GL_ARB_shader_objects"))
+ {
+ wglMakeCurrent (NULL, NULL);
+ wglDeleteContext (display_win32->dummy_context_wgl.hglrc);
+
+ g_set_error_literal (error, GDK_GL_ERROR,
+ GDK_GL_ERROR_NOT_AVAILABLE,
+ _("No GL implementation is available"));
+
+ return FALSE;
+ }
+ }
+
display_win32->hasWglARBCreateContext =
epoxy_has_wgl_extension (hdc, "WGL_ARB_create_context");
display_win32->hasWglEXTSwapControl =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]