Commit e647f553 authored by Nigel Stewart's avatar Nigel Stewart Committed by Nigel Stewart
Browse files

[CoreSupport] Linux/GLX touch-ups for extension string parsing and enable lookup.

parent c996c06b
......@@ -10,6 +10,8 @@
#endif
#include <stddef.h> /* For size_t */
#include <string.h> /* memset, etc */
#include <stdlib.h>
/*
* Define glewGetContext and related helper macros.
......@@ -207,7 +209,6 @@ static GLuint _glewStrCLen (const GLubyte* s, GLubyte c)
return (s[i] == '\0' || s[i] == c) ? i : 0;
}
#if 0
static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n)
{
GLuint i=0;
......@@ -216,7 +217,6 @@ static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n)
while (i < n && a[i] != '\0' && b[i] != '\0' && a[i] == b[i]) i++;
return i == n ? GL_TRUE : GL_FALSE;
}
#endif
static GLboolean _glewStrSame1 (const GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb)
{
......@@ -270,3 +270,23 @@ static GLboolean _glewStrSame3 (const GLubyte** a, GLuint* na, const GLubyte* b,
}
return GL_FALSE;
}
/*
* 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.
*/
static GLboolean _glewSearchExtension (const char* name, const GLubyte *start, const GLubyte *end)
{
const GLubyte* p;
GLuint len = _glewStrLen((const GLubyte*)name);
p = start;
while (p < end)
{
GLuint n = _glewStrCLen(p, ' ');
if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
p += n+1;
}
return GL_FALSE;
}
......@@ -2,7 +2,7 @@
static int _glewExtensionCompare(const void *a, const void *b)
{
return strcmp((const char *) a, *(const char**) b);
return strcmp((const char *) a, *(const char * const *) b);
}
static GLboolean *_glewGetExtensionString(const char *name)
......@@ -67,11 +67,6 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
const GLubyte* s;
GLuint dot;
GLint major, minor;
char *begin;
char *end;
char *i;
char *j;
GLboolean *enable;
/* query opengl version */
s = glGetString(GL_VERSION);
......@@ -121,6 +116,7 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
GLint i;
PFNGLGETSTRINGIPROC getStringi;
const char *ext;
GLboolean *enable;
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
......@@ -144,10 +140,18 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
}
else
{
begin = (char *) glGetString(GL_EXTENSIONS);
if (begin)
const char *ext;
char *begin;
char *end;
char *i;
char *j;
GLboolean *enable;
ext = (const char *) glGetString(GL_EXTENSIONS);
if (ext)
{
begin = strdup(begin);
begin = strdup(ext);
end = begin + strlen(begin);
for (i=begin; i<end; i = j + 1)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment