2006-07-18 23:21:48 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-01-22 00:45:36 +08:00
|
|
|
*
|
|
|
|
* 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>
|
2007-08-01 01:28:09 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
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
|
|
|
|
2001-09-20 05:19:47 +08:00
|
|
|
namespace osg {
|
|
|
|
|
2006-03-09 00:11:54 +08:00
|
|
|
/** Return floating-point OpenGL version number.
|
|
|
|
* Note: Must only be called within a valid OpenGL context,
|
|
|
|
* undefined behavior may occur otherwise.
|
|
|
|
*/
|
|
|
|
extern OSG_EXPORT float getGLVersionNumber();
|
|
|
|
|
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-26 21:15:27 +08:00
|
|
|
extern OSG_EXPORT bool isGLExtensionSupported(unsigned int contextID, 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.
|
|
|
|
*/
|
2005-11-23 18:16:25 +08:00
|
|
|
extern OSG_EXPORT void* getGLExtensionFuncPtr(const char *funcName);
|
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);
|
|
|
|
}
|
|
|
|
|
2007-09-10 23:19:23 +08:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
bool setGLExtensionFuncPtr(T& t, const char* str1)
|
|
|
|
{
|
|
|
|
void* data = osg::getGLExtensionFuncPtr(str1);
|
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
memcpy(&t, &data, sizeof(T));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t = 0;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
bool setGLExtensionFuncPtr(T& t, const char* str1, const char* str2)
|
|
|
|
{
|
|
|
|
void* data = osg::getGLExtensionFuncPtr(str1,str2);
|
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
memcpy(&t, &data, sizeof(T));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t = 0;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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-26 21:15:27 +08:00
|
|
|
extern OSG_EXPORT bool isGLUExtensionSupported(unsigned int contextID, 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
|