summaryrefslogtreecommitdiff
path: root/src/common.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2011-02-05 22:10:48 +0300
committerAndrey Nazarov <skuller@skuller.net>2011-02-05 23:34:40 +0300
commitffe5f8a1ae577ecbc60b7cc130c07135a662e21a (patch)
treeab5bd729270e408720cd901741b93c2eca5f9d8c /src/common.c
parentd638b00fb17e1abef14cac8f09c6f2c801a6b6f1 (diff)
Implement generic GL extension string parser.
Split QGL_ParseExtensionString into Com_ParseExtensionString, to be shared between QGL and GLX/WGL subsystems.
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c
index 28b007b..29cc07b 100644
--- a/src/common.c
+++ b/src/common.c
@@ -1311,6 +1311,45 @@ color_index_t Com_ParseColor( const char *s, color_index_t last ) {
return COLOR_NONE;
}
+#if USE_REF == REF_GL
+/*
+================
+Com_ParseExtensionString
+
+Helper function to parse an OpenGL-style extension string.
+================
+*/
+unsigned Com_ParseExtensionString( const char *s, const char *const extnames[] ) {
+ unsigned mask;
+ const char *p;
+ size_t l1, l2;
+ int i;
+
+ if( !s ) {
+ return 0;
+ }
+
+ mask = 0;
+ while( *s ) {
+ p = Q_strchrnul( s, ' ' );
+ l1 = p - s;
+ for( i = 0; extnames[i]; i++ ) {
+ l2 = strlen( extnames[i] );
+ if( l1 == l2 && !memcmp( s, extnames[i], l1 ) ) {
+ mask |= 1 << i;
+ break;
+ }
+ }
+ if( !*p ) {
+ break;
+ }
+ s = p + 1;
+ }
+
+ return mask;
+}
+#endif
+
/*
================
Com_PlayerToEntityState