2003-07-06 15:01:13 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GLEW, just like OpenGL or GLU, does not rely on the standard C library.
|
|
|
|
* These functions implement the functionality required in this file.
|
|
|
|
*/
|
|
|
|
|
2003-09-15 16:53:02 +00:00
|
|
|
static GLuint _glewStrLen (const GLubyte *s)
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
2003-09-15 16:53:02 +00:00
|
|
|
GLuint i=0;
|
2003-07-06 15:01:13 +00:00
|
|
|
while (s+i != NULL && s[i] != '\0') i++;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2003-09-15 16:53:02 +00:00
|
|
|
static GLuint _glewStrCLen (const GLubyte *s, GLubyte c)
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
2003-09-15 16:53:02 +00:00
|
|
|
GLuint i=0;
|
2003-07-06 15:01:13 +00:00
|
|
|
while (s+i != NULL && s[i] != '\0' && s[i] != c) i++;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2003-09-15 16:53:02 +00:00
|
|
|
static GLboolean _glewStrSame (const GLubyte *a, const GLubyte *b, GLuint n)
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
2003-09-15 16:53:02 +00:00
|
|
|
GLuint i=0;
|
2003-07-06 15:01:13 +00:00
|
|
|
while (i < n && a+i != NULL && b+i != NULL && a[i] == b[i]) i++;
|
|
|
|
return i == n;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Search for name in the extensions string. Use of strstr()
|
|
|
|
* is not sufficient because extension names can be prefixes of
|
|
|
|
* other extension names. Could use strtok() but the constant
|
|
|
|
* string returned by glGetString might be in read-only memory.
|
|
|
|
*/
|
2003-09-12 03:50:22 +00:00
|
|
|
GLboolean glewGetExtension (const GLubyte *name)
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
2003-09-15 16:53:02 +00:00
|
|
|
GLubyte *p, *end;
|
|
|
|
GLuint len = _glewStrLen(name);
|
|
|
|
p = glGetString(GL_EXTENSIONS);
|
2003-07-06 15:01:13 +00:00
|
|
|
if (0 == p) return GL_FALSE;
|
|
|
|
end = p + _glewStrLen(p);
|
|
|
|
while (p < end)
|
|
|
|
{
|
2003-09-15 16:53:02 +00:00
|
|
|
GLuint n = _glewStrCLen(p, ' ');
|
2003-07-06 15:01:13 +00:00
|
|
|
if (len == n && _glewStrSame(name, p, n)) return GL_TRUE;
|
|
|
|
p += n+1;
|
|
|
|
}
|
|
|
|
return GL_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static GLuint _glewInit ()
|
|
|
|
{
|
2003-09-15 16:53:02 +00:00
|
|
|
GLubyte* s;
|
|
|
|
GLuint i;
|
2003-07-06 15:01:13 +00:00
|
|
|
/* query opengl version */
|
2003-09-15 16:53:02 +00:00
|
|
|
s = glGetString(GL_VERSION);
|
2003-07-06 15:01:13 +00:00
|
|
|
if (!s) return GLEW_ERROR_NO_GL_VERSION;
|
|
|
|
i=_glewStrCLen(s, '.')+1;
|
|
|
|
if (s+i == NULL || s[i] < '1')
|
|
|
|
{
|
|
|
|
return GLEW_ERROR_GL_VERSION_10_ONLY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (s[2] == '4')
|
|
|
|
{
|
|
|
|
GLEW_VERSION_1_1 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_2 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_3 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_4 = GL_TRUE;
|
|
|
|
}
|
|
|
|
if (s[2] == '3')
|
|
|
|
{
|
|
|
|
GLEW_VERSION_1_1 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_2 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_3 = GL_TRUE;
|
|
|
|
}
|
|
|
|
if (s[2] == '2')
|
|
|
|
{
|
|
|
|
GLEW_VERSION_1_1 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_2 = GL_TRUE;
|
|
|
|
}
|
|
|
|
if (s[2] < '2')
|
|
|
|
{
|
|
|
|
GLEW_VERSION_1_1 = GL_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* initialize extensions */
|