fix for OGL 2.0 problem

git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@416 783a27ee-832a-0410-bc00-9f386506c6dd
This commit is contained in:
ikits 2005-04-05 03:49:48 +00:00
parent ddb1b56915
commit 9fae23bbfd
2 changed files with 61 additions and 71 deletions

View File

@ -103,21 +103,25 @@ void* dlGetProcAddress (const GLubyte* name)
static GLuint _glewStrLen (const GLubyte* s) static GLuint _glewStrLen (const GLubyte* s)
{ {
GLuint i=0; GLuint i=0;
while (s+i != NULL && s[i] != '\0') i++; if (s == NULL) return 0;
while (s[i] != '\0') i++;
return i; return i;
} }
static GLuint _glewStrCLen (const GLubyte* s, GLubyte c) static GLuint _glewStrCLen (const GLubyte* s, GLubyte c)
{ {
GLuint i=0; GLuint i=0;
while (s+i != NULL && s[i] != '\0' && s[i] != c) i++; if (s == NULL) return 0;
return i; while (s[i] != '\0' && s[i] != c) i++;
return s[i] == c ? i : 0;
} }
static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n) static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n)
{ {
GLuint i=0; GLuint i=0;
while (i < n && a+i != NULL && b+i != NULL && a[i] == b[i]) i++; if(a == NULL || b == NULL)
return (a == NULL && b == NULL && n == 0) ? GL_TRUE : GL_FALSE;
while (i < n && a[i] != '\0' && b[i] != '\0' && a[i] == b[i]) i++;
return i == n ? GL_TRUE : GL_FALSE; return i == n ? GL_TRUE : GL_FALSE;
} }

View File

@ -31,28 +31,15 @@ static
GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
{ {
const GLubyte* s; const GLubyte* s;
GLuint major, minor; GLuint dot, major, minor;
/* check for SiS driver */
s = glGetString(GL_RENDERER);
if (s && _glewStrSame(s,(const GLubyte*)"SiS",3))
{
GLEW_VERSION_1_1 = GL_TRUE;
GLEW_VERSION_1_2 = GL_FALSE;
GLEW_VERSION_1_3 = GL_FALSE;
GLEW_VERSION_1_4 = GL_FALSE;
GLEW_VERSION_1_5 = GL_FALSE;
GLEW_VERSION_2_0 = GL_FALSE;
}
else
{
/* query opengl version */ /* query opengl version */
s = glGetString(GL_VERSION); s = glGetString(GL_VERSION);
if (!s) return GLEW_ERROR_NO_GL_VERSION; dot = _glewStrCLen(s, '.');
major = _glewStrCLen(s, '.')-1; major = dot-1;
minor = _glewStrCLen(s, '.')+1; minor = dot+1;
if (s+major == NULL if (dot == 0 || s[minor] == '\0')
|| s+minor-1 == NULL || s+minor == NULL return GLEW_ERROR_NO_GL_VERSION;
|| (s[major] == 1 && s[minor] < '1')) if (s[major] == '1' && s[minor] == '0')
{ {
return GLEW_ERROR_GL_VERSION_10_ONLY; return GLEW_ERROR_GL_VERSION_10_ONLY;
} }
@ -116,5 +103,4 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
} }
} }
} }
}
/* initialize extensions */ /* initialize extensions */