[Piglit] [PATCH 14/29] util: Fix GLES 1.x version string parsing
Pauli Nieminen
pauli.nieminen at linux.intel.com
Mon May 21 11:08:49 PDT 2012
Signed-off-by: Pauli Nieminen <pauli.nieminen at linux.intel.com>
---
tests/util/piglit-util.c | 27 ++++++++++++++++++++++-----
1 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index 6bde4af..25d3e31 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -107,10 +107,22 @@ void piglit_glutInit(int argc, char **argv)
#endif
}
+static const char * const gl_prefix[] = {
+ "OpenGL ES-CM ",
+ "OpenGL ES-CL ",
+ "OpenGL ES ",
+ NULL,
+};
+
bool piglit_is_gles()
{
const char *version_string = (const char *) glGetString(GL_VERSION);
- return strncmp("OpenGL ES ", version_string, 10) == 0;
+ int i;
+ for (i = 0; gl_prefix[i] != NULL; i++) {
+ if (strncmp(gl_prefix[i], version_string, strlen(gl_prefix[i])) == 0)
+ return true;
+ }
+ return false;
}
int piglit_get_gl_version()
@@ -120,12 +132,17 @@ int piglit_get_gl_version()
int scanf_count;
int major;
int minor;
+ int i;
/* skip to version number */
- if (strncmp("OpenGL ES ", version_string, 10) == 0)
- version_number_string = version_string + 10;
- else
- version_number_string = version_string;
+ version_number_string = version_string;
+ for (i = 0; gl_prefix[i] != NULL; i++) {
+ const int string_len = strlen(gl_prefix[i]);
+ if (strncmp(gl_prefix[i], version_string, string_len) == 0) {
+ version_number_string = version_string + string_len;
+ break;
+ }
+ }
/* Interpret version number */
scanf_count = sscanf(version_number_string, "%i.%i", &major, &minor);
--
1.7.5.4
More information about the Piglit
mailing list