[gtk+] gl: Add gdk_gl_context_get_version()
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gl: Add gdk_gl_context_get_version()
- Date: Thu, 12 Feb 2015 14:52:55 +0000 (UTC)
commit 390a42fa605e99362ac307bf568113dcdad41cdc
Author: Emmanuele Bassi <ebassi gnome org>
Date: Thu Feb 12 14:28:22 2015 +0000
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().
docs/reference/gdk/gdk3-sections.txt | 5 ++++
gdk/gdkglcontext.c | 35 +++++++++++++++++++++++++++++++++-
gdk/gdkglcontext.h | 4 +++
3 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index e90b782..7335636 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 ec6c0a5..1ffacca 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 d6d5f39..089d746 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]