2003-01-22 00:45:36 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
|
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2001-10-04 23:12:57 +08:00
|
|
|
|
2001-09-20 05:19:47 +08:00
|
|
|
#ifndef OSG_GLEXTENSIONS
|
|
|
|
#define OSG_GLEXTENSIONS 1
|
|
|
|
|
|
|
|
#include <osg/Export>
|
2003-08-20 18:38:54 +08:00
|
|
|
#include <string>
|
2001-09-20 05:19:47 +08:00
|
|
|
|
2002-08-20 18:14:12 +08:00
|
|
|
#if defined(WIN32)
|
2002-08-25 03:35:00 +08:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2004-08-02 17:11:31 +08:00
|
|
|
#ifndef NOMINMAX
|
|
|
|
#define NOMINMAX
|
|
|
|
#endif // NOMINMAX
|
2002-08-25 03:35:00 +08:00
|
|
|
#include <windows.h>
|
2004-03-08 19:02:05 +08:00
|
|
|
#elif defined(__APPLE__)
|
2002-08-25 03:35:00 +08:00
|
|
|
#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 {
|
|
|
|
|
2003-08-20 18:38:54 +08:00
|
|
|
|
|
|
|
|
2004-09-13 23:14:11 +08:00
|
|
|
/** Return true if OpenGL "extension" is supported.
|
|
|
|
* Note: Must only be called within a valid OpenGL context,
|
2001-09-29 04:10:41 +08:00
|
|
|
* undefined behavior may occur otherwise.
|
2004-09-13 23:14:11 +08:00
|
|
|
*/
|
2005-04-12 01:14:17 +08:00
|
|
|
extern OSG_EXPORT bool isGLExtensionSupported(const char *extension);
|
2001-09-20 05:19:47 +08:00
|
|
|
|
2004-09-13 23:14:11 +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
|
2004-09-13 23:14:11 +08:00
|
|
|
* is compiled locally to the calling code. This should get by Windows'
|
2002-08-20 18:14:12 +08:00
|
|
|
* dumb implementation of having different GL function ptr's for each
|
2004-09-13 23:14:11 +08:00
|
|
|
* library when linked to it.
|
|
|
|
*/
|
2002-08-20 18:14:12 +08:00
|
|
|
inline void* getGLExtensionFuncPtr(const char *funcName)
|
|
|
|
{
|
|
|
|
#if defined(WIN32)
|
2003-07-24 04:50:56 +08:00
|
|
|
|
2002-09-13 04:30:41 +08:00
|
|
|
return (void*)wglGetProcAddress(funcName);
|
2003-07-24 04:50:56 +08:00
|
|
|
|
2004-03-08 19:02:05 +08:00
|
|
|
#elif defined(__APPLE__)
|
2003-07-24 04:50:56 +08:00
|
|
|
|
2002-08-20 18:14:12 +08:00
|
|
|
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;
|
2003-07-24 04:50:56 +08:00
|
|
|
|
2004-05-09 02:41:18 +08:00
|
|
|
#elif defined (__sun)
|
|
|
|
|
|
|
|
static void *handle = dlopen((const char *)0L, RTLD_LAZY);
|
|
|
|
return dlsym(handle, funcName);
|
|
|
|
|
|
|
|
#elif defined (__sgi)
|
2003-07-24 04:50:56 +08:00
|
|
|
|
|
|
|
static void *handle = dlopen((const char *)0L, RTLD_LAZY);
|
|
|
|
return dlsym(handle, funcName);
|
|
|
|
|
2002-08-20 18:14:12 +08:00
|
|
|
#else // all other unixes
|
2003-07-24 04:50:56 +08:00
|
|
|
|
2002-09-28 01:47:47 +08:00
|
|
|
return dlsym(0, funcName);
|
2003-07-24 04:50:56 +08:00
|
|
|
|
2002-08-20 18:14:12 +08:00
|
|
|
#endif
|
|
|
|
}
|
2001-09-20 05:19:47 +08:00
|
|
|
|
2004-09-13 23:14:11 +08:00
|
|
|
/** 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.
|
2003-08-20 18:38:54 +08:00
|
|
|
* The format of the string is:
|
|
|
|
* "GLRendererString : ExtensionName, ExtensionName; GLRenderString2 : ExtensionName;"
|
|
|
|
* An example of is : "SUN_XVR1000:GL_EXT_texture_filter_anisotropic"
|
2004-09-13 23:14:11 +08:00
|
|
|
* The default setting of GLExtensionDisableString is obtained from the OSG_GL_EXTENSION_DISABLE
|
2003-08-20 18:38:54 +08:00
|
|
|
* environmental variable.
|
2004-09-13 23:14:11 +08:00
|
|
|
*/
|
2005-04-12 01:14:17 +08:00
|
|
|
extern OSG_EXPORT void setGLExtensionDisableString(const std::string& disableString);
|
2003-08-20 18:38:54 +08:00
|
|
|
|
2004-09-13 23:14:11 +08:00
|
|
|
/** Get the list of extensions that are disabled for various OpenGL renderers. */
|
2005-04-12 01:14:17 +08:00
|
|
|
extern OSG_EXPORT std::string& getGLExtensionDisableString();
|
2003-08-20 18:38:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2004-09-13 23:14:11 +08:00
|
|
|
/** Return the address of the specified OpenGL function. If not found then
|
2002-07-12 00:12:24 +08:00
|
|
|
* check a second function name, if this fails then return NULL as function is
|
2004-09-13 23:14:11 +08:00
|
|
|
* not supported by OpenGL library. This is used for checking something
|
2002-07-12 00:12:24 +08:00
|
|
|
* like glActiveTexture (which is in OGL1.3) or glActiveTextureARB.
|
2004-09-13 23:14:11 +08:00
|
|
|
*/
|
2002-07-12 00:12:24 +08:00
|
|
|
inline void* getGLExtensionFuncPtr(const char *funcName,const char *fallbackFuncName)
|
|
|
|
{
|
|
|
|
void* ptr = getGLExtensionFuncPtr(funcName);
|
|
|
|
if (ptr) return ptr;
|
|
|
|
return getGLExtensionFuncPtr(fallbackFuncName);
|
|
|
|
}
|
|
|
|
|
2004-09-13 23:14:11 +08:00
|
|
|
/** Return true if OpenGL "extension" is supported.
|
|
|
|
* Note: Must only be called within a valid OpenGL context,
|
2002-08-26 18:24:01 +08:00
|
|
|
* undefined behavior may occur otherwise.
|
2004-09-13 23:14:11 +08:00
|
|
|
*/
|
2005-04-12 01:14:17 +08:00
|
|
|
extern OSG_EXPORT 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
|