diff options
author | Andrey Nazarov <skuller@skuller.net> | 2011-02-05 22:10:48 +0300 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2011-02-05 23:34:40 +0300 |
commit | ffe5f8a1ae577ecbc60b7cc130c07135a662e21a (patch) | |
tree | ab5bd729270e408720cd901741b93c2eca5f9d8c /src/common.c | |
parent | d638b00fb17e1abef14cac8f09c6f2c801a6b6f1 (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.c | 39 |
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 |