1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

Rewrite glGetProcAddress for MacOsX

This commit is contained in:
Sten Appelt 2017-11-14 20:50:07 +01:00 committed by Sergey Lipskiy
parent e1c7a44593
commit 9d735212f0

View File

@ -33,23 +33,17 @@ typedef struct __GLXFBConfigRec *GLXFBConfig;
#define GL_GET_PROC_ADR(proc_type, proc_name) g_##proc_name = (proc_type) glGetProcAddress((const GLubyte*)#proc_name) #define GL_GET_PROC_ADR(proc_type, proc_name) g_##proc_name = (proc_type) glGetProcAddress((const GLubyte*)#proc_name)
#elif defined(OS_MAC_OS_X) #elif defined(OS_MAC_OS_X)
#import <mach-o/dyld.h> #include <dlfcn.h>
#import <stdlib.h>
#import <string.h> static void* AppleGLGetProcAddress (const char *name)
void * MyNSGLGetProcAddress (const char *name)
{ {
NSSymbol symbol; static void* image = NULL;
char *symbolName; if (NULL == image)
symbolName = (char*)malloc (strlen (name) + 2); // 1 image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY);
strcpy(symbolName + 1, name); // 2
symbolName[0] = '_'; // 3 return (image ? dlsym(image, name) : NULL);
symbol = NULL;
if (NSIsSymbolNameDefined (symbolName)) // 4
symbol = NSLookupAndBindSymbol (symbolName);
free (symbolName); // 5
return symbol ? NSAddressOfSymbol (symbol) : NULL; // 6
} }
#define glGetProcAddress MyNSGLGetProcAddress #define glGetProcAddress AppleGLGetProcAddress
#define GL_GET_PROC_ADR(proc_type, proc_name) g_##proc_name = (proc_type) glGetProcAddress(#proc_name) #define GL_GET_PROC_ADR(proc_type, proc_name) g_##proc_name = (proc_type) glGetProcAddress(#proc_name)
#endif #endif