glcontext: assert all contexts set the version on realize()

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.
This commit is contained in:
Benjamin Otte
2023-04-25 22:45:34 +02:00
parent d33b82249b
commit 7c7a3d67ca

View 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,