diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2015-02-12 14:28:22 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2015-02-12 14:29:44 +0000 |
commit | 390a42fa605e99362ac307bf568113dcdad41cdc (patch) | |
tree | 890ff714b0e53385ec0e78e205610c2653c150e1 /gdk/gdkglcontext.c | |
parent | f52a59d4148dedc40d8e942f120c7999a39ffec7 (diff) | |
download | gtk+-390a42fa605e99362ac307bf568113dcdad41cdc.tar.gz |
gl: Add gdk_gl_context_get_version()
Store the OpenGL version when we first do the extensions check; this
allows client code to check the available GL version without requiring a
call to gdk_gl_context_make_current() and epoxy_gl_version().
Diffstat (limited to 'gdk/gdkglcontext.c')
-rw-r--r-- | gdk/gdkglcontext.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c index ec6c0a53f9..1ffacca43f 100644 --- a/gdk/gdkglcontext.c +++ b/gdk/gdkglcontext.c @@ -95,6 +95,7 @@ typedef struct { int major; int minor; + int gl_version; guint realized : 1; guint use_texture_rectangle : 1; @@ -617,6 +618,8 @@ gdk_gl_context_check_extensions (GdkGLContext *context) if (priv->extensions_checked) return; + priv->gl_version = epoxy_gl_version (); + has_npot = epoxy_has_gl_extension ("GL_ARB_texture_non_power_of_two"); has_texture_rectangle = epoxy_has_gl_extension ("GL_ARB_texture_rectangle"); @@ -633,12 +636,14 @@ gdk_gl_context_check_extensions (GdkGLContext *context) g_warning ("GL implementation doesn't support any form of non-power-of-two textures"); GDK_NOTE (OPENGL, - g_print ("Extensions checked:\n" + g_print ("OpenGL version: %d.%d\n" + "Extensions checked:\n" " - GL_ARB_texture_non_power_of_two: %s\n" " - GL_ARB_texture_rectangle: %s\n" " - GL_EXT_framebuffer_blit: %s\n" " - GL_GREMEDY_frame_terminator: %s\n" "Using texture rectangle: %s\n", + priv->gl_version / 10, priv->gl_version % 10, has_npot ? "yes" : "no", has_texture_rectangle ? "yes" : "no", priv->has_gl_framebuffer_blit ? "yes" : "no", @@ -799,6 +804,34 @@ gdk_gl_context_get_shared_context (GdkGLContext *context) } /** + * gdk_gl_context_get_version: + * @context: a #GdkGLContext + * @major: (out): return location for the major version + * @minor: (out): return location for the minor version + * + * Retrieves the OpenGL version of the @context. + * + * The @context must be realized prior to calling this function. + * + * Since: 3.16 + */ +void +gdk_gl_context_get_version (GdkGLContext *context, + int *major, + int *minor) +{ + GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context); + + g_return_if_fail (GDK_IS_GL_CONTEXT (context)); + g_return_if_fail (priv->realized); + + if (major != NULL) + *major = priv->gl_version / 10; + if (minor != NULL) + *minor = priv->gl_version % 10; +} + +/** * gdk_gl_context_clear_current: * * Clears the current #GdkGLContext. |