summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2023-03-10 17:58:56 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2023-03-10 18:39:09 +0800
commitbdbd8edc56a4056340701fd992217045d57ed4d9 (patch)
tree4dac9795a0b63901fa3c76064df60483e2fb84b5
parent70fe37cf1b05600c9139012fdb0b0a8c5008ffd8 (diff)
downloadgtk+-bdbd8edc56a4056340701fd992217045d57ed4d9.tar.gz
GDK/Win32: Re-enable libANGLE GLES to workwin32-egl-angle
For libANGLE on Windows, it only supports GLES but not enough desktop GL, even with the EGL_KHR_create_context extension, so check whether we are using a libANGLE EGL implementation and enforce that we only allow the GLES API set just before we realize the context, if that is the case.
-rw-r--r--gdk/win32/gdkdisplay-win32.c6
-rw-r--r--gdk/win32/gdkglcontext-win32-egl.c18
2 files changed, 24 insertions, 0 deletions
diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c
index 5c53f247c2..44fabe3bf1 100644
--- a/gdk/win32/gdkdisplay-win32.c
+++ b/gdk/win32/gdkdisplay-win32.c
@@ -1205,6 +1205,9 @@ gdk_win32_display_init_gl (GdkDisplay *display,
FALSE,
error))
{
+ if (display->have_egl_win32_libangle)
+ g_message ("libANGLE EGL contexts currently support OpenGL/ES API only");
+
return g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL,
"display", display,
NULL);
@@ -1230,6 +1233,9 @@ gdk_win32_display_init_gl (GdkDisplay *display,
TRUE,
error))
{
+ if (display->have_egl_win32_libangle)
+ g_message ("libANGLE EGL contexts currently support OpenGL/ES API only");
+
return g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL,
"display", display,
NULL);
diff --git a/gdk/win32/gdkglcontext-win32-egl.c b/gdk/win32/gdkglcontext-win32-egl.c
index 0e8854de49..9978d0692f 100644
--- a/gdk/win32/gdkglcontext-win32-egl.c
+++ b/gdk/win32/gdkglcontext-win32-egl.c
@@ -124,6 +124,23 @@ gdk_win32_gl_context_egl_begin_frame (GdkDrawContext *draw_context,
GDK_DRAW_CONTEXT_CLASS (gdk_win32_gl_context_egl_parent_class)->begin_frame (draw_context, prefers_high_depth, update_area);
}
+static GdkGLAPI
+gdk_win32_gl_context_egl_realize (GdkGLContext *context,
+ GError **error)
+{
+ GdkGLContextClass *klass = GDK_GL_CONTEXT_CLASS (gdk_win32_gl_context_egl_parent_class);
+ GdkDisplay *display = gdk_gl_context_get_display (context);
+
+ /*
+ * force OpenGL/ES API if libANGLE is being used, since libANGLE does not
+ * implement enough Desktop OpenGL even with the EGL_KHR_create_context extension
+ */
+ if (display->have_egl_win32_libangle)
+ gdk_gl_context_set_use_es (context, 1);
+
+ return klass->realize (context, error);
+}
+
static void
gdk_win32_gl_context_egl_class_init (GdkWin32GLContextClass *klass)
{
@@ -131,6 +148,7 @@ gdk_win32_gl_context_egl_class_init (GdkWin32GLContextClass *klass)
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS(klass);
context_class->backend_type = GDK_GL_EGL;
+ context_class->realize = gdk_win32_gl_context_egl_realize;
draw_context_class->begin_frame = gdk_win32_gl_context_egl_begin_frame;
draw_context_class->end_frame = gdk_win32_gl_context_egl_end_frame;