mirror of
https://github.com/nigels-com/glew.git
synced 2024-12-01 01:57:08 +00:00
[CoreSupport] Linux/GLX touch-ups for extension string parsing and enable lookup.
This commit is contained in:
parent
ed7f3857c1
commit
041e5efc85
@ -7,6 +7,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h> /* For size_t */
|
#include <stddef.h> /* For size_t */
|
||||||
|
#include <string.h> /* memset, etc */
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define glewGetContext and related helper macros.
|
* Define glewGetContext and related helper macros.
|
||||||
@ -202,7 +204,6 @@ static GLuint _glewStrCLen (const GLubyte* s, GLubyte c)
|
|||||||
return (s[i] == '\0' || s[i] == c) ? i : 0;
|
return (s[i] == '\0' || s[i] == c) ? i : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 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;
|
||||||
@ -211,7 +212,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++;
|
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;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static GLboolean _glewStrSame1 (const GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb)
|
static GLboolean _glewStrSame1 (const GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb)
|
||||||
{
|
{
|
||||||
@ -265,3 +265,23 @@ static GLboolean _glewStrSame3 (const GLubyte** a, GLuint* na, const GLubyte* b,
|
|||||||
}
|
}
|
||||||
return GL_FALSE;
|
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)
|
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)
|
static GLboolean *_glewGetExtensionString(const char *name)
|
||||||
@ -67,11 +67,6 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
|
|||||||
const GLubyte* s;
|
const GLubyte* s;
|
||||||
GLuint dot;
|
GLuint dot;
|
||||||
GLint major, minor;
|
GLint major, minor;
|
||||||
char *begin;
|
|
||||||
char *end;
|
|
||||||
char *i;
|
|
||||||
char *j;
|
|
||||||
GLboolean *enable;
|
|
||||||
|
|
||||||
/* query opengl version */
|
/* query opengl version */
|
||||||
s = glGetString(GL_VERSION);
|
s = glGetString(GL_VERSION);
|
||||||
@ -121,6 +116,7 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
|
|||||||
GLint i;
|
GLint i;
|
||||||
PFNGLGETSTRINGIPROC getStringi;
|
PFNGLGETSTRINGIPROC getStringi;
|
||||||
const char *ext;
|
const char *ext;
|
||||||
|
GLboolean *enable;
|
||||||
|
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||||
|
|
||||||
@ -144,10 +140,18 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
begin = (char *) glGetString(GL_EXTENSIONS);
|
const char *ext;
|
||||||
if (begin)
|
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);
|
end = begin + strlen(begin);
|
||||||
for (i=begin; i<end; i = j + 1)
|
for (i=begin; i<end; i = j + 1)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user