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.
|
|
|
|
*/
|
|
|
|
|
2004-02-01 18:13:05 +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;
|
|
|
|
}
|
|
|
|
|
2004-02-01 18:13:05 +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;
|
|
|
|
}
|
|
|
|
|
2004-02-01 18:13:05 +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.
|
|
|
|
*/
|
2004-02-01 22:27:31 +00:00
|
|
|
GLboolean glewGetExtension (const char* name)
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
2004-02-01 18:13:05 +00:00
|
|
|
GLubyte* p;
|
|
|
|
GLubyte* end;
|
2004-02-01 22:27:31 +00:00
|
|
|
GLuint len = _glewStrLen((const GLubyte*)name);
|
2003-09-15 17:01:44 +00:00
|
|
|
p = (GLubyte*)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, ' ');
|
2004-02-01 22:27:31 +00:00
|
|
|
if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
|
2003-07-06 15:01:13 +00:00
|
|
|
p += n+1;
|
|
|
|
}
|
|
|
|
return GL_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2004-02-19 04:37:07 +00:00
|
|
|
#ifndef GLEW_MX
|
|
|
|
static
|
|
|
|
#endif
|
2004-02-19 09:43:14 +00:00
|
|
|
GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
2003-09-15 17:01:44 +00:00
|
|
|
const GLubyte* s;
|
2003-09-15 16:53:02 +00:00
|
|
|
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;
|
2004-01-19 21:18:33 +00:00
|
|
|
i = _glewStrCLen(s, '.')+1;
|
2004-02-23 20:35:23 +00:00
|
|
|
if (s+i-1 == NULL || s+i == NULL || s[i] < '1')
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
|
|
|
return GLEW_ERROR_GL_VERSION_10_ONLY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-02-23 20:35:23 +00:00
|
|
|
if (s[i] >= '5')
|
2004-01-19 21:18:33 +00:00
|
|
|
{
|
2004-02-19 04:37:07 +00:00
|
|
|
GLEW_VERSION_1_1 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_2 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_3 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_4 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_5 = GL_TRUE;
|
2004-01-19 21:18:33 +00:00
|
|
|
}
|
2004-02-23 20:35:23 +00:00
|
|
|
if (s[i] == '4')
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
2004-02-19 04:37:07 +00:00
|
|
|
GLEW_VERSION_1_1 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_2 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_3 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_4 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_5 = GL_FALSE;
|
2003-07-06 15:01:13 +00:00
|
|
|
}
|
2004-02-23 20:35:23 +00:00
|
|
|
if (s[i] == '3')
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
2004-02-19 04:37:07 +00:00
|
|
|
GLEW_VERSION_1_1 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_2 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_3 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_4 = GL_FALSE;
|
|
|
|
GLEW_VERSION_1_5 = GL_FALSE;
|
2003-07-06 15:01:13 +00:00
|
|
|
}
|
2004-02-23 20:35:23 +00:00
|
|
|
if (s[i] == '2')
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
2004-02-19 04:37:07 +00:00
|
|
|
GLEW_VERSION_1_1 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_2 = GL_TRUE;
|
|
|
|
GLEW_VERSION_1_3 = GL_FALSE;
|
|
|
|
GLEW_VERSION_1_4 = GL_FALSE;
|
|
|
|
GLEW_VERSION_1_5 = GL_FALSE;
|
2003-07-06 15:01:13 +00:00
|
|
|
}
|
2004-02-23 20:35:23 +00:00
|
|
|
if (s[i] < '2')
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
2004-02-19 04:37:07 +00:00
|
|
|
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;
|
2003-07-06 15:01:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* initialize extensions */
|