summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2015-02-12 14:28:22 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2015-02-12 14:29:44 +0000
commit390a42fa605e99362ac307bf568113dcdad41cdc (patch)
tree890ff714b0e53385ec0e78e205610c2653c150e1
parentf52a59d4148dedc40d8e942f120c7999a39ffec7 (diff)
downloadgtk+-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().
-rw-r--r--docs/reference/gdk/gdk3-sections.txt5
-rw-r--r--gdk/gdkglcontext.c35
-rw-r--r--gdk/gdkglcontext.h4
3 files changed, 43 insertions, 1 deletions
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index e90b782731..7335636bd5 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -1291,6 +1291,9 @@ GdkGLContext
gdk_gl_context_get_display
gdk_gl_context_get_window
gdk_gl_context_get_shared_context
+gdk_gl_context_get_version
+
+<SUBSECTION>
gdk_gl_context_set_required_version
gdk_gl_context_get_required_version
gdk_gl_context_set_debug_enabled
@@ -1300,6 +1303,8 @@ gdk_gl_context_get_forward_compatible
GdkGLProfile
gdk_gl_context_set_profile
gdk_gl_context_get_profile
+
+<SUBSECTION>
GdkGLError
gdk_gl_context_realize
gdk_gl_context_make_current
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.
diff --git a/gdk/gdkglcontext.h b/gdk/gdkglcontext.h
index d6d5f39333..089d746c39 100644
--- a/gdk/gdkglcontext.h
+++ b/gdk/gdkglcontext.h
@@ -48,6 +48,10 @@ GDK_AVAILABLE_IN_3_16
GdkWindow * gdk_gl_context_get_window (GdkGLContext *context);
GDK_AVAILABLE_IN_3_16
GdkGLContext * gdk_gl_context_get_shared_context (GdkGLContext *context);
+GDK_AVAILABLE_IN_3_16
+void gdk_gl_context_get_version (GdkGLContext *context,
+ int *major,
+ int *minor);
GDK_AVAILABLE_IN_3_16
void gdk_gl_context_set_required_version (GdkGLContext *context,