mirror of
https://github.com/Perlmint/glew-cmake.git
synced 2024-11-30 10:27:09 +00:00
Merge https://github.com/nigels-com/glew.git into master HEAD at Thu Jan 7 17:44:14 GMT 2016
This commit is contained in:
commit
573806ef49
@ -10,7 +10,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h> /* For size_t */
|
#include <stddef.h> /* For size_t */
|
||||||
#include <stdlib.h> /* For malloc, free */
|
#include <stdlib.h> /* For bsearch */
|
||||||
#include <string.h> /* For memset */
|
#include <string.h> /* For memset */
|
||||||
|
|
||||||
#if defined(GLEW_REGAL)
|
#if defined(GLEW_REGAL)
|
||||||
@ -166,25 +166,19 @@ static GLuint _glewStrCLen (const GLubyte* s, GLubyte c)
|
|||||||
GLuint i=0;
|
GLuint i=0;
|
||||||
if (s == NULL) return 0;
|
if (s == NULL) return 0;
|
||||||
while (s[i] != '\0' && s[i] != c) i++;
|
while (s[i] != '\0' && s[i] != c) i++;
|
||||||
return (s[i] == '\0' || s[i] == c) ? i : 0;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLubyte *_glewStrDup (const GLubyte *s)
|
static GLuint _glewStrCopy(char *d, const char *s, char c)
|
||||||
{
|
{
|
||||||
int n = _glewStrLen(s);
|
GLuint i=0;
|
||||||
GLubyte *dup = malloc(n+1);
|
if (s == NULL) return 0;
|
||||||
if (dup)
|
while (s[i] != '\0' && s[i] != c) { d[i] = s[i]; i++; }
|
||||||
{
|
d[i] = '\0';
|
||||||
GLubyte *i = dup;
|
return i;
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
*i = *s;
|
|
||||||
if (*i) { ++i; ++s; } else break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(GLEW_OSMESA)
|
||||||
#if !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
#if !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
||||||
static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n)
|
static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n)
|
||||||
{
|
{
|
||||||
@ -195,6 +189,7 @@ static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n)
|
|||||||
return i == n ? GL_TRUE : GL_FALSE;
|
return i == n ? GL_TRUE : GL_FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#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)
|
||||||
{
|
{
|
||||||
@ -255,6 +250,7 @@ static GLboolean _glewStrSame3 (const GLubyte** a, GLuint* na, const GLubyte* b,
|
|||||||
* other extension names. Could use strtok() but the constant
|
* other extension names. Could use strtok() but the constant
|
||||||
* string returned by glGetString might be in read-only memory.
|
* string returned by glGetString might be in read-only memory.
|
||||||
*/
|
*/
|
||||||
|
#if !defined(GLEW_OSMESA)
|
||||||
#if !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
#if !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
||||||
static GLboolean _glewSearchExtension (const char* name, const GLubyte *start, const GLubyte *end)
|
static GLboolean _glewSearchExtension (const char* name, const GLubyte *start, const GLubyte *end)
|
||||||
{
|
{
|
||||||
@ -270,3 +266,4 @@ static GLboolean _glewSearchExtension (const char* name, const GLubyte *start, c
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
@ -2,13 +2,25 @@
|
|||||||
|
|
||||||
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 * const *) b);
|
/* http://www.chanduthedev.com/2012/07/strcmp-implementation-in-c.html */
|
||||||
|
const char *s1 = (const char *) a;
|
||||||
|
const char *s2 = *(const char * const *) b;
|
||||||
|
while (*s1 || *s2)
|
||||||
|
{
|
||||||
|
if (*s1 > *s2)
|
||||||
|
return 1;
|
||||||
|
if (*s1 < *s2)
|
||||||
|
return -1;
|
||||||
|
s1++;
|
||||||
|
s2++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLboolean *_glewGetExtensionString(const char *name)
|
static GLboolean *_glewGetExtensionString(const char *name)
|
||||||
{
|
{
|
||||||
const char **n = (const char **) bsearch(name, _glewExtensionLookup, sizeof(_glewExtensionLookup)/sizeof(char *)-1, sizeof(char *), _glewExtensionCompare);
|
const char **n = (const char **) bsearch(name, _glewExtensionLookup, sizeof(_glewExtensionLookup)/sizeof(char *)-1, sizeof(char *), _glewExtensionCompare);
|
||||||
int i;
|
ptrdiff_t i;
|
||||||
|
|
||||||
if (n)
|
if (n)
|
||||||
{
|
{
|
||||||
@ -22,7 +34,7 @@ static GLboolean *_glewGetExtensionString(const char *name)
|
|||||||
static GLboolean *_glewGetExtensionEnable(const char *name)
|
static GLboolean *_glewGetExtensionEnable(const char *name)
|
||||||
{
|
{
|
||||||
const char **n = (const char **) bsearch(name, _glewExtensionLookup, sizeof(_glewExtensionLookup)/sizeof(char *)-1, sizeof(char *), _glewExtensionCompare);
|
const char **n = (const char **) bsearch(name, _glewExtensionLookup, sizeof(_glewExtensionLookup)/sizeof(char *)-1, sizeof(char *), _glewExtensionCompare);
|
||||||
int i;
|
ptrdiff_t i;
|
||||||
|
|
||||||
if (n)
|
if (n)
|
||||||
{
|
{
|
||||||
@ -33,17 +45,17 @@ static GLboolean *_glewGetExtensionEnable(const char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *_glewNextSpace(char *i)
|
static const char *_glewNextSpace(const char *i)
|
||||||
{
|
{
|
||||||
char *j = i;
|
const char *j = i;
|
||||||
if (j)
|
if (j)
|
||||||
while (*j!=' ' && *j) ++j;
|
while (*j!=' ' && *j) ++j;
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *_glewNextNonSpace(char *i)
|
static const char *_glewNextNonSpace(const char *i)
|
||||||
{
|
{
|
||||||
char *j = i;
|
const char *j = i;
|
||||||
if (j)
|
if (j)
|
||||||
while (*j==' ') ++j;
|
while (*j==' ') ++j;
|
||||||
return j;
|
return j;
|
||||||
@ -137,35 +149,37 @@ static GLenum GLEWAPIENTRY glewContextInit ()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const GLubyte *ext;
|
const char *extensions;
|
||||||
char *begin;
|
const char *end;
|
||||||
char *end;
|
const char *i;
|
||||||
char *i;
|
const char *j;
|
||||||
char *j;
|
char ext[128];
|
||||||
GLboolean *enable;
|
GLboolean *enable;
|
||||||
|
|
||||||
ext = glGetString(GL_EXTENSIONS);
|
extensions = (const char *) glGetString(GL_EXTENSIONS);
|
||||||
|
|
||||||
if (ext)
|
if (extensions)
|
||||||
{
|
{
|
||||||
begin = (char *) _glewStrDup(ext);
|
end = extensions + _glewStrLen((const GLubyte *) extensions);
|
||||||
end = begin + _glewStrLen((GLubyte *) begin);
|
for (i=extensions; i<end; i = j + 1)
|
||||||
for (i=begin; i<end; i = j + 1)
|
|
||||||
{
|
{
|
||||||
i = _glewNextNonSpace(i);
|
i = _glewNextNonSpace(i);
|
||||||
j = _glewNextSpace(i);
|
j = _glewNextSpace(i);
|
||||||
*j = 0;
|
|
||||||
|
/* Copy extension into NUL terminated string */
|
||||||
|
if (j-i >= (ptrdiff_t) sizeof(ext))
|
||||||
|
continue;
|
||||||
|
_glewStrCopy(ext, i, ' ');
|
||||||
|
|
||||||
/* Based on extension string(s), glewGetExtension purposes */
|
/* Based on extension string(s), glewGetExtension purposes */
|
||||||
enable = _glewGetExtensionString(i);
|
enable = _glewGetExtensionString(ext);
|
||||||
if (enable)
|
if (enable)
|
||||||
*enable = GL_TRUE;
|
*enable = GL_TRUE;
|
||||||
|
|
||||||
/* Based on extension string(s), experimental mode, glewIsSupported purposes */
|
/* Based on extension string(s), experimental mode, glewIsSupported purposes */
|
||||||
enable = _glewGetExtensionEnable(i);
|
enable = _glewGetExtensionEnable(ext);
|
||||||
if (enable)
|
if (enable)
|
||||||
*enable = GL_TRUE;
|
*enable = GL_TRUE;
|
||||||
}
|
}
|
||||||
free(begin);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ POPT = -O2
|
|||||||
CFLAGS.EXTRA += -fPIC
|
CFLAGS.EXTRA += -fPIC
|
||||||
CFLAGS.EXTRA += -Wcast-qual
|
CFLAGS.EXTRA += -Wcast-qual
|
||||||
CFLAGS.EXTRA += -ansi -pedantic
|
CFLAGS.EXTRA += -ansi -pedantic
|
||||||
|
CFLAGS.EXTRA += -fno-stack-protector
|
||||||
BIN.SUFFIX =
|
BIN.SUFFIX =
|
||||||
LIB.SONAME = lib$(NAME).so.$(SO_MAJOR)
|
LIB.SONAME = lib$(NAME).so.$(SO_MAJOR)
|
||||||
LIB.DEVLNK = lib$(NAME).so
|
LIB.DEVLNK = lib$(NAME).so
|
||||||
|
@ -25,6 +25,7 @@ POPT = -O2
|
|||||||
CFLAGS.EXTRA += -fPIC
|
CFLAGS.EXTRA += -fPIC
|
||||||
CFLAGS.EXTRA += -Wcast-qual
|
CFLAGS.EXTRA += -Wcast-qual
|
||||||
CFLAGS.EXTRA += -ansi -pedantic
|
CFLAGS.EXTRA += -ansi -pedantic
|
||||||
|
CFLAGS.EXTRA += -fno-stack-protector
|
||||||
BIN.SUFFIX =
|
BIN.SUFFIX =
|
||||||
LIB.SONAME = lib$(NAME).so.$(SO_MAJOR)
|
LIB.SONAME = lib$(NAME).so.$(SO_MAJOR)
|
||||||
LIB.DEVLNK = lib$(NAME).so
|
LIB.DEVLNK = lib$(NAME).so
|
||||||
|
Loading…
Reference in New Issue
Block a user