From a91b8fa40a132cb67fda1d6d6692d037008e3cfb Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 23 Nov 2005 10:16:25 +0000 Subject: [PATCH] Moved getGLExtensionFuncPtr implementation into the .cpp to make it easier to change it implementation without forcing a complete recompile. --- include/osg/GLExtensions | 53 +--------------------------------------- src/osg/GLExtensions.cpp | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 52 deletions(-) diff --git a/include/osg/GLExtensions b/include/osg/GLExtensions index e8f9ac1a5..7b73ac8a6 100644 --- a/include/osg/GLExtensions +++ b/include/osg/GLExtensions @@ -17,22 +17,9 @@ #include #include -#if defined(WIN32) - #define WIN32_LEAN_AND_MEAN - #ifndef NOMINMAX - #define NOMINMAX - #endif // NOMINMAX - #include -#elif defined(__APPLE__) - #include -#else - #include -#endif namespace osg { - - /** Return true if OpenGL "extension" is supported. * Note: Must only be called within a valid OpenGL context, * undefined behavior may occur otherwise. @@ -46,43 +33,7 @@ extern OSG_EXPORT bool isGLExtensionSupported(unsigned int contextID, const char * dumb implementation of having different GL function ptr's for each * library when linked to it. */ -inline void* getGLExtensionFuncPtr(const char *funcName) -{ -#if defined(WIN32) - - return (void*)wglGetProcAddress(funcName); - -#elif defined(__APPLE__) - - std::string temp( "_" ); - temp += funcName; // Mac OS X prepends an underscore on function names - if ( NSIsSymbolNameDefined( temp.c_str() ) ) - { - NSSymbol symbol = NSLookupAndBindSymbol( temp.c_str() ); - return NSAddressOfSymbol( symbol ); - } else - return NULL; - -#elif defined (__sun) - - static void *handle = dlopen((const char *)0L, RTLD_LAZY); - return dlsym(handle, funcName); - -#elif defined (__sgi) - - static void *handle = dlopen((const char *)0L, RTLD_LAZY); - return dlsym(handle, funcName); - -#elif defined (__FreeBSD__) - - return dlsym( RTLD_DEFAULT, funcName ); - -#else // all other unixes - - return dlsym(0, funcName); - -#endif -} +extern OSG_EXPORT void* getGLExtensionFuncPtr(const char *funcName); /** Set a list of extensions to disable for different OpenGL renderers. This allows * OSG applications to work around OpenGL drivers' bugs which are due to problematic extension support. @@ -97,8 +48,6 @@ extern OSG_EXPORT void setGLExtensionDisableString(const std::string& disableStr /** Get the list of extensions that are disabled for various OpenGL renderers. */ extern OSG_EXPORT std::string& getGLExtensionDisableString(); - - /** Return the address of the specified OpenGL function. If not found then * check a second function name, if this fails then return NULL as function is * not supported by OpenGL library. This is used for checking something diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index 536392085..d445b6787 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -201,3 +201,53 @@ bool osg::isGLUExtensionSupported(unsigned int contextID, const char *extension) return result; } + +#if defined(WIN32) + #define WIN32_LEAN_AND_MEAN + #ifndef NOMINMAX + #define NOMINMAX + #endif // NOMINMAX + #include +#elif defined(__APPLE__) + #include +#else + #include +#endif + +void* osg::getGLExtensionFuncPtr(const char *funcName) +{ +#if defined(WIN32) + + return (void*)wglGetProcAddress(funcName); + +#elif defined(__APPLE__) + + std::string temp( "_" ); + temp += funcName; // Mac OS X prepends an underscore on function names + if ( NSIsSymbolNameDefined( temp.c_str() ) ) + { + NSSymbol symbol = NSLookupAndBindSymbol( temp.c_str() ); + return NSAddressOfSymbol( symbol ); + } else + return NULL; + +#elif defined (__sun) + + static void *handle = dlopen((const char *)0L, RTLD_LAZY); + return dlsym(handle, funcName); + +#elif defined (__sgi) + + static void *handle = dlopen((const char *)0L, RTLD_LAZY); + return dlsym(handle, funcName); + +#elif defined (__FreeBSD__) + + return dlsym( RTLD_DEFAULT, funcName ); + +#else // all other unixes + + return dlsym(0, funcName); + +#endif +}