/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifdef MAC_OS_X_VERSION_10_3 #include #else #include #endif static void* AppleGLGetProcAddress (const GLubyte *name) { #ifdef MAC_OS_X_VERSION_10_3 static struct GLLibrary { void * glLibrary; GLLibrary(const char * glLibPath) { glLibrary = dlopen(glLibPath, RTLD_LAZY); if (!glLibrary) { const char * error = dlerror(); // handle error } } ~GLLibrary() { if (glLibrary) { if (dlclose(glLibrary) != 0) { // problem... } glLibrary = NULL; } } operator void *() { return glLibrary; } } cGLLibrary("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"); if(name == NULL) return NULL; if(cGLLibrary == NULL) return NULL; return dlsym(cGLLibrary, (const char*)name); #else static const struct mach_header* image = NULL; NSSymbol symbol; char* symbolName; if (NULL == image) { image = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR); } /* prepend a '_' for the Unix C symbol mangling convention */ symbolName = (char*)malloc(strlen((const char*)name) + 2); strcpy(symbolName+1, (const char*)name); symbolName[0] = '_'; symbol = NULL; /* if (NSIsSymbolNameDefined(symbolName)) symbol = NSLookupAndBindSymbol(symbolName); */ symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL; free(symbolName); return symbol ? NSAddressOfSymbol(symbol) : NULL; #endif }