From 471af2c0d6ddb8a450ecfc5ea5a7404b64f558d1 Mon Sep 17 00:00:00 2001 From: ikits Date: Tue, 4 Jan 2005 05:31:44 +0000 Subject: [PATCH] extended glewIsSupported git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@343 783a27ee-832a-0410-bc00-9f386506c6dd --- auto/bin/make_str.pl | 18 ++++++++++-------- auto/src/glew_head.c | 34 ++++++++++++++++++++++++++++++---- auto/src/glew_str_glx.c | 9 +++++++-- auto/src/glew_str_head.c | 5 ++++- auto/src/glew_str_tail.c | 4 +++- auto/src/glew_str_wgl.c | 9 +++++++-- auto/src/glew_utils.c | 34 ++++++++++++++++++++++++++++++---- auto/src/glew_utils.h | 3 ++- 8 files changed, 93 insertions(+), 23 deletions(-) diff --git a/auto/bin/make_str.pl b/auto/bin/make_str.pl index f29e8d5..062bfbc 100755 --- a/auto/bin/make_str.pl +++ b/auto/bin/make_str.pl @@ -15,8 +15,6 @@ do 'bin/make.pl'; my @extlist = (); my %extensions = (); -our $export = shift; - if (@ARGV) { @extlist = @ARGV; @@ -35,17 +33,21 @@ if (@ARGV) { if(length($curexttype) > 0) { - print " }\n"; + print " }\n"; } - print " if (_glewStrSame2(&pos, &len, (const GLubyte*)\"$exttype\", " . length($exttype) . "))\n"; - print " {\n"; + print " if (_glewStrSame2(&pos, &len, (const GLubyte*)\"$exttype\", " . length($exttype) . "))\n"; + print " {\n"; $curexttype = $exttype; } print "#ifdef $extname\n"; - print " if (_glewStrSame3(pos, len, (const GLubyte*)\"$extrem\", ". length($extrem) . "))\n"; - print " return $extvar;\n"; + print " if (_glewStrSame3(&pos, &len, (const GLubyte*)\"$extrem\", ". length($extrem) . "))\n"; + #print " return $extvar;\n"; + print " {\n"; + print " ret = $extvar;\n"; + print " continue;\n"; + print " }\n"; print "#endif\n"; } - print " }\n"; + print " }\n"; } diff --git a/auto/src/glew_head.c b/auto/src/glew_head.c index 7d0502d..cf244ef 100644 --- a/auto/src/glew_head.c +++ b/auto/src/glew_head.c @@ -121,6 +121,27 @@ GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n) return i == n ? GL_TRUE : GL_FALSE; } +GLboolean _glewStrSame1 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) +{ + while (*na > 0 && (**a == ' ' || **a == '\n' || **a == '\r' || **a == '\t')) + { + *a++; + *na--; + } + if(*na >= nb) + { + GLuint i=0; + while (i < nb && *a+i != NULL && b+i != NULL && *a[i] == b[i]) i++; + if(i == nb) + { + *a = *a + nb; + *na = *na - nb; + return GL_TRUE; + } + } + return GL_FALSE; +} + GLboolean _glewStrSame2 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) { if(*na >= nb) @@ -137,13 +158,18 @@ GLboolean _glewStrSame2 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) return GL_FALSE; } -GLboolean _glewStrSame3 (const GLubyte* a, GLuint na, const GLubyte* b, GLuint nb) +GLboolean _glewStrSame3 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) { - if(na == nb) + if(*na >= nb) { GLuint i=0; - while (i < nb && a+i != NULL && b+i != NULL && a[i] == b[i]) i++; - return i == nb ? GL_TRUE : GL_FALSE; + while (i < nb && *a+i != NULL && b+i != NULL && *a[i] == b[i]) i++; + if (i == nb && (*na == nb || *a[i] == ' ' || *a[i] == '\n' || *a[i] == '\r' || *a[i] == '\t')) + { + *a = *a + nb; + *na = *na - nb; + return GL_TRUE; + } } return GL_FALSE; } diff --git a/auto/src/glew_str_glx.c b/auto/src/glew_str_glx.c index 0ba4d48..7c31405 100644 --- a/auto/src/glew_str_glx.c +++ b/auto/src/glew_str_glx.c @@ -1,5 +1,7 @@ + } + ret = (len == 0); } - return GL_FALSE; + return ret; } #elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) @@ -12,5 +14,8 @@ GLboolean glxewIsSupported (const char* name) { GLubyte* pos = (GLubyte*)name; GLuint len = _glewStrLen(pos); - if(_glewStrSame2(&pos, &len, (const GLubyte*)"GLX_", 4)) + GLboolean ret = GL_TRUE; + while (ret && len > 0) { + if(_glewStrSame1(&pos, &len, (const GLubyte*)"GLX_", 4)) + { diff --git a/auto/src/glew_str_head.c b/auto/src/glew_str_head.c index 5596954..1f3ddf2 100644 --- a/auto/src/glew_str_head.c +++ b/auto/src/glew_str_head.c @@ -6,5 +6,8 @@ GLboolean glewIsSupported (const char* name) { GLubyte* pos = (GLubyte*)name; GLuint len = _glewStrLen(pos); - if(_glewStrSame2(&pos, &len, (const GLubyte*)"GL_", 3)) + GLboolean ret = GL_TRUE; + while (ret && len > 0) { + if (_glewStrSame1(&pos, &len, (const GLubyte*)"GL_", 3)) + { diff --git a/auto/src/glew_str_tail.c b/auto/src/glew_str_tail.c index 3ae4429..caa9572 100644 --- a/auto/src/glew_str_tail.c +++ b/auto/src/glew_str_tail.c @@ -1,5 +1,7 @@ + } + ret = (len == 0); } - return GL_FALSE; + return ret; } #endif /* _WIN32 */ diff --git a/auto/src/glew_str_wgl.c b/auto/src/glew_str_wgl.c index bdee238..2398075 100644 --- a/auto/src/glew_str_wgl.c +++ b/auto/src/glew_str_wgl.c @@ -1,5 +1,7 @@ + } + ret = (len == 0); } - return GL_FALSE; + return ret; } #if defined(_WIN32) @@ -12,5 +14,8 @@ GLboolean wglewIsSupported (const char* name) { GLubyte* pos = (GLubyte*)name; GLuint len = _glewStrLen(pos); - if(_glewStrSame2(&pos, &len, (const GLubyte*)"WGL_", 4)) + GLboolean ret = GL_TRUE; + while (ret && len > 0) { + if (_glewStrSame1(&pos, &len, (const GLubyte*)"WGL_", 4)) + { diff --git a/auto/src/glew_utils.c b/auto/src/glew_utils.c index 6d5a182..09e8b67 100644 --- a/auto/src/glew_utils.c +++ b/auto/src/glew_utils.c @@ -108,6 +108,27 @@ GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n) return i == n ? GL_TRUE : GL_FALSE; } +GLboolean _glewStrSame1 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) +{ + while (*na > 0 && (**a == ' ' || **a == '\n' || **a == '\r' || **a == '\t')) + { + *a++; + *na--; + } + if(*na >= nb) + { + GLuint i=0; + while (i < nb && *a+i != NULL && b+i != NULL && *a[i] == b[i]) i++; + if(i == nb) + { + *a = *a + nb; + *na = *na - nb; + return GL_TRUE; + } + } + return GL_FALSE; +} + GLboolean _glewStrSame2 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) { if(*na >= nb) @@ -124,13 +145,18 @@ GLboolean _glewStrSame2 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) return GL_FALSE; } -GLboolean _glewStrSame3 (const GLubyte* a, GLuint na, const GLubyte* b, GLuint nb) +GLboolean _glewStrSame3 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) { - if(na == nb) + if(*na >= nb) { GLuint i=0; - while (i < nb && a+i != NULL && b+i != NULL && a[i] == b[i]) i++; - return i == nb ? GL_TRUE : GL_FALSE; + while (i < nb && *a+i != NULL && b+i != NULL && *a[i] == b[i]) i++; + if (i == nb && (*na == nb || *a[i] == ' ' || *a[i] == '\n' || *a[i] == '\r' || *a[i] == '\t')) + { + *a = *a + nb; + *na = *na - nb; + return GL_TRUE; + } } return GL_FALSE; } diff --git a/auto/src/glew_utils.h b/auto/src/glew_utils.h index 08e4a57..10ba6ba 100644 --- a/auto/src/glew_utils.h +++ b/auto/src/glew_utils.h @@ -94,7 +94,8 @@ extern GLuint _glewStrLen (const GLubyte* s); extern GLuint _glewStrCLen (const GLubyte* s, GLubyte c); extern GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n); +extern GLboolean _glewStrSame1 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb); extern GLboolean _glewStrSame2 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb); -extern GLboolean _glewStrSame3 (const GLubyte* a, GLuint na, const GLubyte* b, GLuint nb); +extern GLboolean _glewStrSame3 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) #endif /* __glew_utils_h__ */