Aded osg::isGLExtensionOrVersionSupported(uint contextID, char* extensionName, float minVersionRequired) method that

returns true if (the extension string is supported or GL version is greater than or equal to a specified version) and 
non extension disable is used.   This makes it possible to disable extensions that are now
available as parts of the core OpenGL spec.

Updated Texture.cpp is use this method.
This commit is contained in:
Robert Osfield 2008-12-15 19:37:14 +00:00
parent f4836d7aa1
commit 528fdbb75c
3 changed files with 100 additions and 80 deletions

View File

@ -38,6 +38,12 @@ extern OSG_EXPORT bool isExtensionInExtensionString(const char *extension, const
*/
extern OSG_EXPORT bool isGLExtensionSupported(unsigned int contextID, const char *extension);
/** Return true if OpenGL "extension" or minimum OpenGL version number is supported.
* Note: Must only be called within a valid OpenGL context,
* undefined behavior may occur otherwise.
*/
extern OSG_EXPORT bool isGLExtensionOrVersionSupported(unsigned int contextID, const char *extension, float requiredGlVersion);
/** Return the address of the specified OpenGL function.
* Return NULL if function not supported by OpenGL library.
* Note, glGLExtensionFuncPtr is declared inline so that the code

View File

@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <float.h>
#include <string>
#include <vector>
@ -68,10 +69,20 @@ bool osg::isExtensionInExtensionString(const char *extension, const char *extens
}
bool osg::isGLExtensionSupported(unsigned int contextID, const char *extension)
{
return osg::isGLExtensionOrVersionSupported(contextID, extension, FLT_MAX);
}
bool osg::isGLExtensionOrVersionSupported(unsigned int contextID, const char *extension, float requiredGLVersion)
{
ExtensionSet& extensionSet = s_glExtensionSetList[contextID];
std::string& rendererString = s_glRendererList[contextID];
// first check to see if GL version number of recent enough.
bool result = requiredGLVersion <= osg::getGLVersionNumber();
if (!result)
{
// if not already set up, initialize all the per graphic context values.
if (!s_glInitializedList[contextID])
{
@ -95,7 +106,7 @@ bool osg::isGLExtensionSupported(unsigned int contextID, const char *extension)
}
if (*startOfWord!=0) extensionSet.insert(std::string(startOfWord));
#if defined(WIN32)
#if defined(WIN32)
// add WGL extensions to the list
@ -131,7 +142,7 @@ bool osg::isGLExtensionSupported(unsigned int contextID, const char *extension)
if (*startOfWord != 0) extensionSet.insert(std::string(startOfWord));
}
#endif
#endif
osg::notify(INFO)<<"OpenGL extensions supported by installed OpenGL drivers are:"<<std::endl;
for(ExtensionSet::iterator itr=extensionSet.begin();
@ -144,7 +155,8 @@ bool osg::isGLExtensionSupported(unsigned int contextID, const char *extension)
}
// true if extension found in extensionSet.
bool result = extensionSet.find(extension)!=extensionSet.end();
result = extensionSet.find(extension)!=extensionSet.end();
}
// now see if extension is in the extension disabled list
bool extensionDisabled = false;

View File

@ -1639,30 +1639,32 @@ void Texture::Extensions::setupGLExtensions(unsigned int contextID)
const char* renderer = (const char*) glGetString(GL_RENDERER);
std::string rendererString(renderer ? renderer : "");
_isMultiTexturingSupported = ( glVersion >= 1.3 ) ||
isGLExtensionSupported(contextID,"GL_ARB_multitexture") ||
isGLExtensionSupported(contextID,"GL_EXT_multitexture");
_isMultiTexturingSupported = isGLExtensionOrVersionSupported( contextID,"GL_ARB_multitexture", 1.3) ||
isGLExtensionOrVersionSupported(contextID,"GL_EXT_multitexture", 1.3);
_isTextureFilterAnisotropicSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_filter_anisotropic");
_isTextureCompressionARBSupported = ( glVersion >= 1.3 ) ||
isGLExtensionSupported(contextID,"GL_ARB_texture_compression");
_isTextureCompressionARBSupported = isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_compression", 1.3);
_isTextureCompressionS3TCSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_compression_s3tc");
_isTextureMirroredRepeatSupported = ( glVersion >= 1.4 ) ||
isGLExtensionSupported(contextID,"GL_IBM_texture_mirrored_repeat") ||
isGLExtensionSupported(contextID,"GL_ARB_texture_mirrored_repeat");
_isTextureEdgeClampSupported = ( glVersion >= 1.2 ) ||
isGLExtensionSupported(contextID,"GL_EXT_texture_edge_clamp") ||
isGLExtensionSupported(contextID,"GL_SGIS_texture_edge_clamp");
_isTextureBorderClampSupported = ( glVersion >= 1.3 ) ||
isGLExtensionSupported(contextID,"GL_ARB_texture_border_clamp");
_isGenerateMipMapSupported = (strncmp((const char*)glGetString(GL_VERSION),"1.4",3)>=0) ||
isGLExtensionSupported(contextID,"GL_SGIS_generate_mipmap");
_isTextureMirroredRepeatSupported = isGLExtensionOrVersionSupported(contextID,"GL_IBM_texture_mirrored_repeat", 1.4) ||
isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_mirrored_repeat", 1.4);
_isTextureEdgeClampSupported = isGLExtensionOrVersionSupported(contextID,"GL_EXT_texture_edge_clamp", 1.2) ||
isGLExtensionOrVersionSupported(contextID,"GL_SGIS_texture_edge_clamp", 1.2);
_isTextureBorderClampSupported = isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_border_clamp", 1.3);
_isGenerateMipMapSupported = isGLExtensionOrVersionSupported(contextID,"GL_SGIS_generate_mipmap", 1.4);
_isShadowSupported = isGLExtensionSupported(contextID,"GL_ARB_shadow");
_isShadowAmbientSupported = isGLExtensionSupported(contextID,"GL_ARB_shadow_ambient");
_isClientStorageSupported = isGLExtensionSupported(contextID,"GL_APPLE_client_storage");
_isNonPowerOfTwoTextureNonMipMappedSupported = ( glVersion >= 2.0 ) ||
isGLExtensionSupported(contextID,"GL_ARB_texture_non_power_of_two");
_isNonPowerOfTwoTextureNonMipMappedSupported = isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_non_power_of_two", 2.0);
_isNonPowerOfTwoTextureMipMappedSupported = _isNonPowerOfTwoTextureNonMipMappedSupported;