[Cogl] [PATCH] check the glsl version during init

Robert Bragg robert at sixbynine.org
Fri Sep 28 04:15:49 PDT 2012


From: Robert Bragg <robert at linux.intel.com>

This adds a check for the glsl version during driver init which gets
stored in ctx->glsl_major and ctx->glsl_minor.
---
 cogl/cogl-context-private.h            |    3 +++
 cogl/driver/gl/gl/cogl-driver-gl.c     |   10 ++++++++++
 cogl/driver/gl/gles/cogl-driver-gles.c |    3 +++
 3 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/cogl/cogl-context-private.h b/cogl/cogl-context-private.h
index 8e35099..cf30007 100644
--- a/cogl/cogl-context-private.h
+++ b/cogl/cogl-context-private.h
@@ -74,6 +74,9 @@ struct _CoglContext
   const CoglDriverVtable *driver_vtable;
   const CoglTextureDriver *texture_driver;
 
+  int glsl_major;
+  int glsl_minor;
+
   /* Features cache */
   unsigned long features[COGL_FLAGS_N_LONGS_FOR_SIZE (_COGL_N_FEATURE_IDS)];
   CoglFeatureFlags feature_flags; /* legacy/deprecated feature flags */
diff --git a/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/driver/gl/gl/cogl-driver-gl.c
index f67dc07..2533002 100644
--- a/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -374,6 +374,16 @@ _cogl_driver_update_features (CoglContext *ctx,
 
   _cogl_gpu_info_init (ctx, &ctx->gpu);
 
+  ctx->glsl_major = 1;
+  ctx->glsl_minor = 1;
+
+  if (COGL_CHECK_GL_VERSION (gl_major, gl_minor, 2, 0))
+    {
+      const char *glsl_version =
+        (char *)ctx->glGetString (GL_SHADING_LANGUAGE_VERSION);
+      parse_gl_version (glsl_version, &ctx->glsl_major, &ctx->glsl_minor);
+    }
+
   flags = (COGL_FEATURE_TEXTURE_READ_PIXELS
            | COGL_FEATURE_UNSIGNED_INT_INDICES
            | COGL_FEATURE_DEPTH_RANGE);
diff --git a/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/driver/gl/gles/cogl-driver-gles.c
index 05262c9..cb17dc5 100644
--- a/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -215,6 +215,9 @@ _cogl_driver_update_features (CoglContext *context,
 
   _cogl_gpu_info_init (context, &context->gpu);
 
+  context->glsl_major = 1;
+  context->glsl_minor = 0;
+
   gl_extensions = _cogl_context_get_gl_extensions (context);
 
   _cogl_feature_check_ext_functions (context,
-- 
1.7.7.6



More information about the Cogl mailing list