[Cogl] [PATCH] driver-gl: split out parse_gl_version function

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


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

This splits out the GL version parser code from
cogl-driver-gl.c:_cogl_get_gl_version() so it can also be used for
parsing other gl version strings.
---
 cogl/driver/gl/gl/cogl-driver-gl.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/driver/gl/gl/cogl-driver-gl.c
index add1f2c..f67dc07 100644
--- a/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -242,17 +242,13 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
 }
 
 static CoglBool
-_cogl_get_gl_version (CoglContext *ctx,
-                      int *major_out,
-                      int *minor_out)
+parse_gl_version (const char *version_string,
+                  int *major_out,
+                  int *minor_out)
 {
-  const char *version_string, *major_end, *minor_end;
+  const char *major_end, *minor_end;
   int major = 0, minor = 0;
 
-  /* Get the OpenGL version number */
-  if ((version_string = _cogl_context_get_gl_version (ctx)) == NULL)
-    return FALSE;
-
   /* Extract the major number */
   for (major_end = version_string; *major_end >= '0'
 	 && *major_end <= '9'; major_end++)
@@ -279,6 +275,20 @@ _cogl_get_gl_version (CoglContext *ctx,
 }
 
 static CoglBool
+_cogl_get_gl_version (CoglContext *ctx,
+                      int *major_out,
+                      int *minor_out)
+{
+  const char *version_string;
+
+  /* Get the OpenGL version number */
+  if ((version_string = _cogl_context_get_gl_version (ctx)) == NULL)
+    return FALSE;
+
+  return parse_gl_version (version_string, major_out, minor_out);
+}
+
+static CoglBool
 check_gl_version (CoglContext *ctx,
                   CoglError **error)
 {
-- 
1.7.7.6



More information about the Cogl mailing list