mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-25 23:31:56 +00:00
added support for maxosx
git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@129 783a27ee-832a-0410-bc00-9f386506c6dd
This commit is contained in:
parent
96541c0e4c
commit
13e1fbe10f
@ -30,41 +30,67 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
#ifdef _WIN32
|
||||||
#include <GL/wglew.h>
|
#include <GL/wglew.h>
|
||||||
|
#else
|
||||||
#include <GL/glxew.h>
|
#include <GL/glxew.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define glewGetProcAddress(name) wglGetProcAddress(name)
|
# define glewGetProcAddress(name) wglGetProcAddress(name)
|
||||||
#else
|
#else
|
||||||
# ifdef GLEW_NEEDS_CUSTOM_GET_PROCADDRESS
|
#ifdef __APPLE__
|
||||||
# define glewGetProcAddress(name) __dlopenGetProcAddress(name)
|
# define glewGetProcAddress(name) NSGLGetProcAddress(name)
|
||||||
# else
|
#else
|
||||||
# define glewGetProcAddress(name) (*glXGetProcAddressARB)(name)
|
#ifdef __sgi
|
||||||
# endif /* GLEW_NEEDS_CUSTOM_GET_PROCADDRESS */
|
# define glewGetProcAddress(name) dlGetProcAddress(name)
|
||||||
#endif /* _WIN32 */
|
#else /* __linux */
|
||||||
|
# define glewGetProcAddress(name) (*glXGetProcAddressARB)(name)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef GLEW_NEEDS_CUSTOM_GET_PROCADDRESS
|
#ifdef __APPLE__
|
||||||
|
#include <mach-o/dyld.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static void* NSGLGetProcAddress (const char* name)
|
||||||
|
{
|
||||||
|
NSSymbol symbol;
|
||||||
|
char* symbolName;
|
||||||
|
// Prepend a '_' for the Unix C symbol mangling convention
|
||||||
|
symbolName = malloc(strlen(name) + 2);
|
||||||
|
strcpy(symbolName+1, name);
|
||||||
|
symbolName[0] = '_';
|
||||||
|
symbol = NULL;
|
||||||
|
if (NSIsSymbolNameDefined(symbolName))
|
||||||
|
symbol = NSLookupAndBindSymbol(symbolName);
|
||||||
|
free(symbolName);
|
||||||
|
return symbol ? NSAddressOfSymbol(symbol) : NULL;
|
||||||
|
}
|
||||||
|
#endif /* __APPLE__ */
|
||||||
|
|
||||||
|
#ifdef __sgi
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static void* __dlopenGetProcAddress (const GLubyte *procName)
|
static void* dlGetProcAddress (const char* name)
|
||||||
{
|
{
|
||||||
static void *h = NULL;
|
static void* h = NULL;
|
||||||
static void *gpa;
|
/* static void *gpa; */
|
||||||
|
|
||||||
if (!h)
|
if (h != NULL)
|
||||||
{
|
{
|
||||||
if (!(h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL))) return NULL;
|
if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL;
|
||||||
gpa = dlsym(h, "glXGetProcAddress");
|
/* gpa = dlsym(h, "glXGetProcAddress"); */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gpa != NULL)
|
/* if (gpa != NULL)
|
||||||
return ((void* (*)(const GLubyte*))gpa)(procName);
|
return ((void* (*)(const GLubyte*))gpa)(procName);
|
||||||
else
|
else */
|
||||||
return dlsym(h, (const char *)procName);
|
return dlsym(h, name);
|
||||||
}
|
}
|
||||||
#endif /* GLEW_NEEDS_CUSTOM_GET_PROCADDRESS */
|
#endif /* __sgi */
|
||||||
|
|
||||||
/* ----------------------------- GL_VERSION_1_1 ---------------------------- */
|
/* ----------------------------- GL_VERSION_1_1 ---------------------------- */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user