[gtk/wip.win32.fixes: 9/23] glcontext: Make sure get_version always return something meaningful
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip.win32.fixes: 9/23] glcontext: Make sure get_version always return something meaningful
- Date: Wed, 1 Jun 2022 02:26:59 +0000 (UTC)
commit 66249bca093871236f308a326f6907ce5a723fae
Author: Pablo Correa Gómez <ablocorrea hotmail com>
Date: Tue May 10 00:21:40 2022 +0200
glcontext: Make sure get_version always return something meaningful
Before, if the context had not been ever made current, it would return 0. Make
sure the return value is never 0 and discourage in the documentation against
the use if the context is not current.
gdk/gdkglcontext.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index a79a1e235f..5dbc8df165 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -1675,7 +1675,8 @@ 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.
+ * The @context must be realized and should be current prior to calling this
+ * function.
*/
void
gdk_gl_context_get_version (GdkGLContext *context,
@@ -1687,6 +1688,14 @@ gdk_gl_context_get_version (GdkGLContext *context,
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
g_return_if_fail (gdk_gl_context_is_realized (context));
+ if (priv->gl_version == 0)
+ {
+ GdkGLContext *current = gdk_gl_context_get_current ();
+ gdk_gl_context_make_current (context);
+ g_assert (priv->gl_version != 0);
+ gdk_gl_context_make_current (current);
+ }
+
if (major != NULL)
*major = priv->gl_version / 10;
if (minor != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]