Apple OSX GLX support via glXGetProcAddress by Stefan Eilemann

git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@636 783a27ee-832a-0410-bc00-9f386506c6dd
This commit is contained in:
nigels 2010-12-27 17:31:48 +00:00
parent 7d2446061a
commit 97b6a17cad

View File

@ -34,6 +34,29 @@
# define GLXEW_CONTEXT_ARG_DEF_LIST void # define GLXEW_CONTEXT_ARG_DEF_LIST void
#endif /* GLEW_MX */ #endif /* GLEW_MX */
#if defined(__sgi) || defined (__sun) || defined(GLEW_APPLE_GLX)
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
void* dlGetProcAddress (const GLubyte* name)
{
static void* h = NULL;
static void* gpa;
if (h == NULL)
{
if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL;
gpa = dlsym(h, "glXGetProcAddress");
}
if (gpa != NULL)
return ((void*(*)(const GLubyte*))gpa)(name);
else
return dlsym(h, (const char*)name);
}
#endif /* __sgi || __sun || GLEW_APPLE_GLX */
#if defined(__APPLE__) #if defined(__APPLE__)
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -50,7 +73,14 @@ void* NSGLGetProcAddress (const GLubyte *name)
{ {
image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY); image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY);
} }
return image ? dlsym(image, (const char*)name) : NULL; if( !image ) return NULL;
void* addr = dlsym(image, (const char*)name);
if( addr ) return addr;
#ifdef GLEW_APPLE_GLX
return dlGetProcAddress( name ); // try next for glx symbols
#else
return NULL;
#endif
} }
#else #else
@ -74,34 +104,16 @@ void* NSGLGetProcAddress (const GLubyte *name)
symbol = NSLookupAndBindSymbol(symbolName); */ symbol = NSLookupAndBindSymbol(symbolName); */
symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL; symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL;
free(symbolName); free(symbolName);
return symbol ? NSAddressOfSymbol(symbol) : NULL; if( symbol ) return NSAddressOfSymbol(symbol);
#ifdef GLEW_APPLE_GLX
return dlGetProcAddress( name ); // try next for glx symbols
#else
return NULL;
#endif
} }
#endif /* MAC_OS_X_VERSION_10_3 */ #endif /* MAC_OS_X_VERSION_10_3 */
#endif /* __APPLE__ */ #endif /* __APPLE__ */
#if defined(__sgi) || defined (__sun)
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
void* dlGetProcAddress (const GLubyte* name)
{
static void* h = NULL;
static void* gpa;
if (h == NULL)
{
if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL;
gpa = dlsym(h, "glXGetProcAddress");
}
if (gpa != NULL)
return ((void*(*)(const GLubyte*))gpa)(name);
else
return dlsym(h, (const char*)name);
}
#endif /* __sgi || __sun */
/* /*
* Define glewGetProcAddress. * Define glewGetProcAddress.
*/ */