GDK-Win32: Make EGL a runtime opt-in
authorChun-wei Fan <fanchunwei@src.gnome.org>
Mon, 8 Nov 2021 07:37:08 +0000 (15:37 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Mon, 8 Nov 2021 07:40:59 +0000 (15:40 +0800)
Use the debug envvar 'GDK_DEBUG=gl-egl' to determine whether we want to try to
initialize EGL first before trying WGL, as a means for people to more easily
enable EGL support on Windows to test EGL there (such as to debug the shaders,
for instance)

gdk/win32/gdkdisplay-win32.c

index dd40b5c13a30fd7a60bfcefb549cb7f4efb271a2..d4a275ec7f947a2e9c6bc1e37f612d9c8708c554 100644 (file)
@@ -1152,21 +1152,23 @@ gdk_win32_display_init_gl_backend (GdkDisplay  *display,
   if (display_win32->dummy_context_wgl.hdc == NULL)
     display_win32->dummy_context_wgl.hdc = GetDC (display_win32->hwnd);
 
-  /* No env vars set, do the regular GL initialization, first WGL and then EGL,
+  /*
+   * No env vars set, do the regular GL initialization, first WGL and then EGL,
    * as WGL is the more tried-and-tested configuration.
    */
 
-/*
- * Disable defaulting to EGL for now, since shaders need to be fixed for
- * usage against libANGLE EGL.  EGL is used more as a compatibility layer
- * on Windows rather than being a native citizen on Windows
- */
-#if 0
-  result = gdk_display_init_egl (display,
-                                 EGL_PLATFORM_ANGLE_ANGLE,
-                                 display_win32->dummy_context_wgl.hdc,
-                                 FALSE,
-                                 error);
+#ifdef HAVE_EGL
+  /*
+   * Disable defaulting to EGL for now, since shaders need to be fixed for
+   * usage against libANGLE EGL.  EGL is used more as a compatibility layer
+   * on Windows rather than being a native citizen on Windows
+   */
+  if (_gdk_debug_flags & GDK_DEBUG_GL_EGL)
+    result = gdk_display_init_egl (display,
+                                   EGL_PLATFORM_ANGLE_ANGLE,
+                                   display_win32->dummy_context_wgl.hdc,
+                                   FALSE,
+                                   error);
 #endif
 
   if (!result)