mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-21 00:18:43 +00:00
Changed: #1004 - implemented nglGetProcAddress using dlsym
This commit is contained in:
parent
3e7ac724ca
commit
542d4125a0
1 changed files with 18 additions and 10 deletions
|
@ -30,20 +30,28 @@ using namespace NLMISC;
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
#define nglGetProcAddress wglGetProcAddress
|
#define nglGetProcAddress wglGetProcAddress
|
||||||
#elif defined(NL_OS_MAC)
|
#elif defined(NL_OS_MAC)
|
||||||
#include <mach-o/dyld.h>
|
// #include <mach-o/dyld.h>
|
||||||
// glXGetProcAddressARB doesn't work correctly on MAC
|
// 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)
|
void *nglGetProcAddress(const char *name)
|
||||||
{
|
{
|
||||||
NSSymbol symbol;
|
return dlsym(RTLD_DEFAULT, name);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
void (*nglGetProcAddress(const char *procName))()
|
void (*nglGetProcAddress(const char *procName))()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue