Changed: #1004 - implemented nglGetProcAddress using dlsym

This commit is contained in:
rti 2010-08-04 20:33:52 +02:00
parent 9c73a06e1b
commit 7f007d2cc1

View file

@ -30,20 +30,28 @@ using namespace NLMISC;
#ifdef NL_OS_WINDOWS
#define nglGetProcAddress wglGetProcAddress
#elif defined(NL_OS_MAC)
#include <mach-o/dyld.h>
// #include <mach-o/dyld.h>
// glXGetProcAddressARB doesn't work correctly on MAC
// void *nglGetProcAddress(const char *name)
// {
// NSSymbol symbol;
// char *symbolName;
// symbolName = (char*)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;
// }
// NSAddressOfSymbol, NSIsSymbolNameDefined, NSLookupAndBindSymbol are deprecated
#include <dlfcn.h>
void *nglGetProcAddress(const char *name)
{
NSSymbol symbol;
char *symbolName;
symbolName = (char*)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;
return dlsym(RTLD_DEFAULT, name);
}
#elif defined (NL_OS_UNIX)
void (*nglGetProcAddress(const char *procName))()
{