2002-07-17 04:07:32 +08:00
|
|
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
|
2001-10-04 23:12:57 +08:00
|
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
|
|
//as published by the Free Software Foundation.
|
|
|
|
|
2001-09-20 05:19:47 +08:00
|
|
|
#ifndef OSG_GLEXTENSIONS
|
|
|
|
#define OSG_GLEXTENSIONS 1
|
|
|
|
|
|
|
|
#include <osg/Export>
|
|
|
|
|
2002-08-20 18:14:12 +08:00
|
|
|
#if defined(WIN32)
|
2002-08-25 03:35:00 +08:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
2002-08-20 18:14:12 +08:00
|
|
|
#elif defined(__DARWIN_OSX__)
|
2002-08-25 03:35:00 +08:00
|
|
|
#include <string>
|
|
|
|
#include <mach-o/dyld.h>
|
2002-08-20 18:14:12 +08:00
|
|
|
#else
|
2002-08-25 03:35:00 +08:00
|
|
|
#include <dlfcn.h>
|
2002-08-20 18:14:12 +08:00
|
|
|
#endif
|
|
|
|
|
2001-09-20 05:19:47 +08:00
|
|
|
namespace osg {
|
|
|
|
|
|
|
|
/** return true if OpenGL "extension" is supported.
|
|
|
|
* note: Must only called within a valid OpenGL context,
|
2001-09-29 04:10:41 +08:00
|
|
|
* undefined behavior may occur otherwise.
|
2001-09-20 05:19:47 +08:00
|
|
|
*/
|
2002-09-02 20:31:35 +08:00
|
|
|
SG_EXPORT extern bool isGLExtensionSupported(const char *extension);
|
2001-09-20 05:19:47 +08:00
|
|
|
|
|
|
|
/** return the address of the specified OpenGL function.
|
|
|
|
* return NULL if function not supported by OpenGL library.
|
2002-08-20 18:14:12 +08:00
|
|
|
* Note, glGLExtensionFuncPtr is declared inline so that the code
|
|
|
|
* is compiled localy to the calling code. This should get by Windows
|
|
|
|
* dumb implementation of having different GL function ptr's for each
|
|
|
|
* library when links to it.
|
2001-09-20 05:19:47 +08:00
|
|
|
*/
|
2002-08-20 18:14:12 +08:00
|
|
|
inline void* getGLExtensionFuncPtr(const char *funcName)
|
|
|
|
{
|
|
|
|
#if defined(WIN32)
|
2002-09-13 04:30:41 +08:00
|
|
|
return (void*)wglGetProcAddress(funcName);
|
2002-08-20 18:14:12 +08:00
|
|
|
#elif defined(__DARWIN_OSX__)
|
|
|
|
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;
|
|
|
|
#else // all other unixes
|
2002-09-28 01:47:47 +08:00
|
|
|
return dlsym(0, funcName);
|
2002-08-20 18:14:12 +08:00
|
|
|
#endif
|
|
|
|
}
|
2001-09-20 05:19:47 +08:00
|
|
|
|
2002-07-12 00:12:24 +08:00
|
|
|
/** 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 usual for checking something
|
|
|
|
* like glActiveTexture (which is in OGL1.3) or glActiveTextureARB.
|
|
|
|
*/
|
|
|
|
inline void* getGLExtensionFuncPtr(const char *funcName,const char *fallbackFuncName)
|
|
|
|
{
|
|
|
|
void* ptr = getGLExtensionFuncPtr(funcName);
|
|
|
|
if (ptr) return ptr;
|
|
|
|
return getGLExtensionFuncPtr(fallbackFuncName);
|
|
|
|
}
|
|
|
|
|
2002-08-26 18:24:01 +08:00
|
|
|
/** return true if OpenGL "extension" is supported.
|
|
|
|
* note: Must only called within a valid OpenGL context,
|
|
|
|
* undefined behavior may occur otherwise.
|
|
|
|
*/
|
2002-09-02 20:31:35 +08:00
|
|
|
SG_EXPORT extern bool isGLUExtensionSupported(const char *extension);
|
2002-08-26 18:24:01 +08:00
|
|
|
|
|
|
|
|
2002-02-03 20:33:41 +08:00
|
|
|
}
|
2001-09-20 05:19:47 +08:00
|
|
|
|
|
|
|
#endif
|