glcontext: Simplify get_required_version api
authorPablo Correa Gómez <ablocorrea@hotmail.com>
Mon, 30 May 2022 18:18:15 +0000 (20:18 +0200)
committerPablo Correa Gómez <ablocorrea@hotmail.com>
Sat, 4 Jun 2022 18:48:40 +0000 (20:48 +0200)
Simplify the API to just return the requirements that the user
has asked for. The rest of the code was undocumented and previously
used as a buggy source for a default value from internal code.
Since the buggy code is now fixed, remove all unnecessary cruft.

gdk/gdkglcontext.c

index 78080a236b5b0c775946bba88c0b1ec4c93dcc64..bf524a2c91fd9ecddb79d3c3bdc9378752926bdd 100644 (file)
@@ -1065,7 +1065,10 @@ gdk_gl_context_check_version (GdkGLContext *self,
  * @major: (out) (nullable): return location for the major version to request
  * @minor: (out) (nullable): return location for the minor version to request
  *
- * Retrieves required OpenGL version.
+ * Retrieves required OpenGL version set as a requirement for the @context
+ * realization. It will not change even if a greater OpenGL version is supported
+ * and used after the @context is realized. See
+ * [method@Gdk.GLContext.get_version] for the real version in use.
  *
  * See [method@Gdk.GLContext.set_required_version].
  */
@@ -1075,47 +1078,14 @@ gdk_gl_context_get_required_version (GdkGLContext *context,
                                      int          *minor)
 {
   GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
-  gboolean force_gles = FALSE;
-  GdkDisplay *display;
-  int default_major, default_minor;
-  int maj, min;
 
   g_return_if_fail (GDK_IS_GL_CONTEXT (context));
 
-  display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
-
-#ifdef G_ENABLE_DEBUG
-  force_gles = GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES);
-#endif
-
-  /* libANGLE on Windows at least requires GLES 3.0+ */
-  if (display->have_egl_win32_libangle)
-    force_gles = TRUE;
-
-  /* Default fallback values for uninitialised contexts; we
-   * enforce a context version number of 3.2 for desktop GL,
-   * and 2.0 for GLES
-   */
-  if (gdk_gl_context_get_use_es (context) || force_gles)
-    {
-      default_major = display->have_egl_win32_libangle ? 3 : 2;
-      default_minor = 0;
-    }
-  else
-    {
-      default_major = 3;
-      default_minor = 2;
-    }
-
-  if (priv->major > 0)
-    maj = priv->major;
-  else
-    maj = default_major;
-
-  if (priv->minor > 0)
-    min = priv->minor;
-  else
-    min = default_minor;
+  if (major != NULL)
+    *major = priv->major;
+  if (minor != NULL)
+    *minor = priv->minor;
+}
 
 void
 gdk_gl_context_get_clipped_version (GdkGLContext *context,