glcontext: assert all contexts set the version on realize()
authorBenjamin Otte <otte@redhat.com>
Tue, 25 Apr 2023 20:45:34 +0000 (22:45 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 27 Apr 2023 00:13:32 +0000 (02:13 +0200)
Now that all contexts do that, insist that they keep doing it.

And because they keep doing it, we can support querying the GL version
from gdk_gl_context_get_version() without requiring the context to be
made current.

gdk/gdkglcontext.c

index 294e58e555e29aab34e0749226a39624f5abf696..9d06a3c266c4668bd8dd2238ecdb89d5cb4ed230 100644 (file)
@@ -1485,7 +1485,11 @@ gdk_gl_context_realize (GdkGLContext  *context,
   priv->api = GDK_GL_CONTEXT_GET_CLASS (context)->realize (context, error);
 
   if (priv->api)
-    g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_API]);
+    {
+      g_assert (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (0, 0)));
+
+      g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_API]);
+    }
 
   return priv->api;
 }
@@ -1511,9 +1515,6 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
   if (priv->extensions_checked)
     return;
 
-  if (!gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (0, 0)))
-    gdk_gl_version_init_epoxy (&priv->gl_version);
-
   priv->has_debug_output = epoxy_has_gl_extension ("GL_ARB_debug_output") ||
                            epoxy_has_gl_extension ("GL_KHR_debug");
 
@@ -1693,10 +1694,6 @@ gdk_gl_context_get_shared_context (GdkGLContext *context)
  * Retrieves the OpenGL version of the @context.
  *
  * The @context must be realized prior to calling this function.
- *
- * If the @context has never been made current, the version cannot
- * be known and it will return 0 for both @major and @minor.
- *
  */
 void
 gdk_gl_context_get_version (GdkGLContext *context,