2003-07-06 15:01:13 +00:00
|
|
|
#include <GL/glew.h>
|
2003-10-27 02:34:05 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
# include <GL/wglew.h>
|
|
|
|
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
|
|
|
|
# include <GL/glxew.h>
|
2003-09-19 23:39:22 +00:00
|
|
|
#endif
|
2003-07-06 15:01:13 +00:00
|
|
|
|
2005-01-03 07:05:38 +00:00
|
|
|
/*
|
|
|
|
* Define glewGetContext and related helper macros.
|
|
|
|
*/
|
|
|
|
#ifdef GLEW_MX
|
|
|
|
# define glewGetContext() ctx
|
|
|
|
# ifdef _WIN32
|
|
|
|
# define GLEW_CONTEXT_ARG_DEF_INIT GLEWContext* ctx
|
|
|
|
# define GLEW_CONTEXT_ARG_VAR_INIT ctx
|
|
|
|
# define wglewGetContext() ctx
|
|
|
|
# define WGLEW_CONTEXT_ARG_DEF_INIT WGLEWContext* ctx
|
|
|
|
# define WGLEW_CONTEXT_ARG_DEF_LIST WGLEWContext* ctx
|
|
|
|
# else /* _WIN32 */
|
|
|
|
# define GLEW_CONTEXT_ARG_DEF_INIT void
|
|
|
|
# define GLEW_CONTEXT_ARG_VAR_INIT
|
|
|
|
# define glxewGetContext() ctx
|
|
|
|
# define GLXEW_CONTEXT_ARG_DEF_INIT void
|
|
|
|
# define GLXEW_CONTEXT_ARG_DEF_LIST GLXEWContext* ctx
|
|
|
|
# endif /* _WIN32 */
|
|
|
|
# define GLEW_CONTEXT_ARG_DEF_LIST GLEWContext* ctx
|
|
|
|
#else /* GLEW_MX */
|
|
|
|
# define GLEW_CONTEXT_ARG_DEF_INIT void
|
|
|
|
# define GLEW_CONTEXT_ARG_VAR_INIT
|
|
|
|
# define GLEW_CONTEXT_ARG_DEF_LIST void
|
|
|
|
# define WGLEW_CONTEXT_ARG_DEF_INIT void
|
|
|
|
# define WGLEW_CONTEXT_ARG_DEF_LIST void
|
|
|
|
# define GLXEW_CONTEXT_ARG_DEF_INIT void
|
|
|
|
# define GLXEW_CONTEXT_ARG_DEF_LIST void
|
|
|
|
#endif /* GLEW_MX */
|
2003-09-19 23:39:22 +00:00
|
|
|
|
2003-10-27 02:34:05 +00:00
|
|
|
#if defined(__APPLE__)
|
2003-09-19 23:39:22 +00:00
|
|
|
#include <mach-o/dyld.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2004-12-29 05:43:35 +00:00
|
|
|
void* NSGLGetProcAddress (const GLubyte *name)
|
2003-09-19 23:39:22 +00:00
|
|
|
{
|
|
|
|
NSSymbol symbol;
|
2004-12-29 05:43:35 +00:00
|
|
|
char* symbolName;
|
2003-09-26 13:49:28 +00:00
|
|
|
/* prepend a '_' for the Unix C symbol mangling convention */
|
2004-12-29 05:43:35 +00:00
|
|
|
symbolName = malloc(strlen((const char*)name) + 2);
|
|
|
|
strcpy(symbolName+1, (const char*)name);
|
2003-09-19 23:39:22 +00:00
|
|
|
symbolName[0] = '_';
|
|
|
|
symbol = NULL;
|
|
|
|
if (NSIsSymbolNameDefined(symbolName))
|
|
|
|
symbol = NSLookupAndBindSymbol(symbolName);
|
|
|
|
free(symbolName);
|
|
|
|
return symbol ? NSAddressOfSymbol(symbol) : NULL;
|
|
|
|
}
|
|
|
|
#endif /* __APPLE__ */
|
2003-07-06 16:41:08 +00:00
|
|
|
|
2003-10-27 05:28:55 +00:00
|
|
|
#if defined(__sgi) || defined (__sun)
|
2003-07-06 16:41:08 +00:00
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2004-12-29 05:43:35 +00:00
|
|
|
void* dlGetProcAddress (const GLubyte* name)
|
2003-07-06 16:41:08 +00:00
|
|
|
{
|
2004-12-29 05:43:35 +00:00
|
|
|
static void* h = NULL;
|
|
|
|
static void* gpa;
|
2003-07-06 16:41:08 +00:00
|
|
|
|
2003-09-26 16:07:24 +00:00
|
|
|
if (h == NULL)
|
2003-09-12 03:50:22 +00:00
|
|
|
{
|
2003-09-19 23:39:22 +00:00
|
|
|
if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL;
|
2003-09-26 16:07:24 +00:00
|
|
|
gpa = dlsym(h, "glXGetProcAddress");
|
2003-09-12 03:50:22 +00:00
|
|
|
}
|
2003-07-06 16:41:08 +00:00
|
|
|
|
2003-09-26 16:07:24 +00:00
|
|
|
if (gpa != NULL)
|
2004-12-29 05:43:35 +00:00
|
|
|
return ((void*(*)(const GLubyte*))gpa)(name);
|
2003-09-26 16:07:24 +00:00
|
|
|
else
|
2004-12-29 05:43:35 +00:00
|
|
|
return dlsym(h, (const char*)name);
|
2003-07-06 16:41:08 +00:00
|
|
|
}
|
2003-10-27 05:28:55 +00:00
|
|
|
#endif /* __sgi || __sun */
|
2003-07-06 15:01:13 +00:00
|
|
|
|
2005-01-03 07:05:38 +00:00
|
|
|
/*
|
|
|
|
* Define glewGetProcAddress.
|
|
|
|
*/
|
|
|
|
#if defined(_WIN32)
|
|
|
|
# define glewGetProcAddress(name) wglGetProcAddress((LPCSTR)name)
|
|
|
|
#else
|
|
|
|
# if defined(__APPLE__)
|
|
|
|
# define glewGetProcAddress(name) NSGLGetProcAddress(name)
|
|
|
|
# else
|
|
|
|
# if defined(__sgi) || defined(__sun)
|
|
|
|
# define glewGetProcAddress(name) dlGetProcAddress(name)
|
|
|
|
# else /* __linux */
|
|
|
|
# define glewGetProcAddress(name) (*glXGetProcAddressARB)(name)
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2004-12-29 05:43:35 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
GLuint _glewStrLen (const GLubyte* s)
|
|
|
|
{
|
|
|
|
GLuint i=0;
|
|
|
|
while (s+i != NULL && s[i] != '\0') i++;
|
|
|
|
return i;
|
|
|
|
}
|
2003-07-06 15:01:13 +00:00
|
|
|
|
2004-12-29 05:43:35 +00:00
|
|
|
GLuint _glewStrCLen (const GLubyte* s, GLubyte c)
|
|
|
|
{
|
|
|
|
GLuint i=0;
|
|
|
|
while (s+i != NULL && s[i] != '\0' && s[i] != c) i++;
|
|
|
|
return i;
|
|
|
|
}
|
2004-02-19 04:37:07 +00:00
|
|
|
|
2004-12-29 05:43:35 +00:00
|
|
|
GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n)
|
|
|
|
{
|
|
|
|
GLuint i=0;
|
|
|
|
while (i < n && a+i != NULL && b+i != NULL && a[i] == b[i]) i++;
|
|
|
|
return i == n ? GL_TRUE : GL_FALSE;
|
|
|
|
}
|
2004-02-19 04:37:07 +00:00
|
|
|
|
2005-01-04 05:31:44 +00:00
|
|
|
GLboolean _glewStrSame1 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb)
|
|
|
|
{
|
|
|
|
while (*na > 0 && (**a == ' ' || **a == '\n' || **a == '\r' || **a == '\t'))
|
|
|
|
{
|
|
|
|
*a++;
|
|
|
|
*na--;
|
|
|
|
}
|
|
|
|
if(*na >= nb)
|
|
|
|
{
|
|
|
|
GLuint i=0;
|
|
|
|
while (i < nb && *a+i != NULL && b+i != NULL && *a[i] == b[i]) i++;
|
|
|
|
if(i == nb)
|
|
|
|
{
|
|
|
|
*a = *a + nb;
|
|
|
|
*na = *na - nb;
|
|
|
|
return GL_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return GL_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-01-04 03:05:50 +00:00
|
|
|
GLboolean _glewStrSame2 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb)
|
2004-12-29 05:43:35 +00:00
|
|
|
{
|
|
|
|
if(*na >= nb)
|
|
|
|
{
|
|
|
|
GLuint i=0;
|
|
|
|
while (i < nb && *a+i != NULL && b+i != NULL && *a[i] == b[i]) i++;
|
|
|
|
if(i == nb)
|
|
|
|
{
|
|
|
|
*a = *a + nb;
|
|
|
|
*na = *na - nb;
|
|
|
|
return GL_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return GL_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-01-04 05:31:44 +00:00
|
|
|
GLboolean _glewStrSame3 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb)
|
2004-12-29 05:43:35 +00:00
|
|
|
{
|
2005-01-04 05:31:44 +00:00
|
|
|
if(*na >= nb)
|
2004-12-29 05:43:35 +00:00
|
|
|
{
|
|
|
|
GLuint i=0;
|
2005-01-04 05:31:44 +00:00
|
|
|
while (i < nb && *a+i != NULL && b+i != NULL && *a[i] == b[i]) i++;
|
|
|
|
if (i == nb && (*na == nb || *a[i] == ' ' || *a[i] == '\n' || *a[i] == '\r' || *a[i] == '\t'))
|
|
|
|
{
|
|
|
|
*a = *a + nb;
|
|
|
|
*na = *na - nb;
|
|
|
|
return GL_TRUE;
|
|
|
|
}
|
2004-12-29 05:43:35 +00:00
|
|
|
}
|
|
|
|
return GL_FALSE;
|
|
|
|
}
|