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:
parent
f4836d7aa1
commit
528fdbb75c
@ -38,6 +38,12 @@ extern OSG_EXPORT bool isExtensionInExtensionString(const char *extension, const
|
|||||||
*/
|
*/
|
||||||
extern OSG_EXPORT bool isGLExtensionSupported(unsigned int contextID, const char *extension);
|
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 the address of the specified OpenGL function.
|
||||||
* Return NULL if function not supported by OpenGL library.
|
* Return NULL if function not supported by OpenGL library.
|
||||||
* Note, glGLExtensionFuncPtr is declared inline so that the code
|
* Note, glGLExtensionFuncPtr is declared inline so that the code
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -68,84 +69,95 @@ bool osg::isExtensionInExtensionString(const char *extension, const char *extens
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool osg::isGLExtensionSupported(unsigned int contextID, const char *extension)
|
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];
|
ExtensionSet& extensionSet = s_glExtensionSetList[contextID];
|
||||||
std::string& rendererString = s_glRendererList[contextID];
|
std::string& rendererString = s_glRendererList[contextID];
|
||||||
|
|
||||||
// if not already set up, initialize all the per graphic context values.
|
// first check to see if GL version number of recent enough.
|
||||||
if (!s_glInitializedList[contextID])
|
bool result = requiredGLVersion <= osg::getGLVersionNumber();
|
||||||
|
|
||||||
|
if (!result)
|
||||||
{
|
{
|
||||||
s_glInitializedList[contextID] = 1;
|
// if not already set up, initialize all the per graphic context values.
|
||||||
|
if (!s_glInitializedList[contextID])
|
||||||
// set up the renderer
|
|
||||||
const GLubyte* renderer = glGetString(GL_RENDERER);
|
|
||||||
rendererString = renderer ? (const char*)renderer : "";
|
|
||||||
|
|
||||||
// get the extension list from OpenGL.
|
|
||||||
const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
|
|
||||||
if (extensions==NULL) return false;
|
|
||||||
|
|
||||||
// insert the ' ' delimiated extensions words into the extensionSet.
|
|
||||||
const char *startOfWord = extensions;
|
|
||||||
const char *endOfWord;
|
|
||||||
while ((endOfWord = strchr(startOfWord,' '))!=NULL)
|
|
||||||
{
|
{
|
||||||
extensionSet.insert(std::string(startOfWord,endOfWord));
|
s_glInitializedList[contextID] = 1;
|
||||||
startOfWord = endOfWord+1;
|
|
||||||
}
|
|
||||||
if (*startOfWord!=0) extensionSet.insert(std::string(startOfWord));
|
|
||||||
|
|
||||||
#if defined(WIN32)
|
// set up the renderer
|
||||||
|
const GLubyte* renderer = glGetString(GL_RENDERER);
|
||||||
|
rendererString = renderer ? (const char*)renderer : "";
|
||||||
|
|
||||||
// add WGL extensions to the list
|
// get the extension list from OpenGL.
|
||||||
|
const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
|
||||||
|
if (extensions==NULL) return false;
|
||||||
|
|
||||||
typedef const char* WINAPI WGLGETEXTENSIONSSTRINGARB(HDC);
|
// insert the ' ' delimiated extensions words into the extensionSet.
|
||||||
WGLGETEXTENSIONSSTRINGARB* wglGetExtensionsStringARB =
|
const char *startOfWord = extensions;
|
||||||
(WGLGETEXTENSIONSSTRINGARB*)getGLExtensionFuncPtr("wglGetExtensionsStringARB");
|
const char *endOfWord;
|
||||||
|
while ((endOfWord = strchr(startOfWord,' '))!=NULL)
|
||||||
typedef const char* WINAPI WGLGETEXTENSIONSSTRINGEXT();
|
|
||||||
WGLGETEXTENSIONSSTRINGEXT* wglGetExtensionsStringEXT =
|
|
||||||
(WGLGETEXTENSIONSSTRINGEXT*)getGLExtensionFuncPtr("wglGetExtensionsStringEXT");
|
|
||||||
|
|
||||||
const char* wglextensions = 0;
|
|
||||||
|
|
||||||
if (wglGetExtensionsStringARB)
|
|
||||||
{
|
|
||||||
HDC dc = wglGetCurrentDC();
|
|
||||||
wglextensions = wglGetExtensionsStringARB(dc);
|
|
||||||
}
|
|
||||||
else if (wglGetExtensionsStringEXT)
|
|
||||||
{
|
|
||||||
wglextensions = wglGetExtensionsStringEXT();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wglextensions)
|
|
||||||
{
|
|
||||||
const char* startOfWord = wglextensions;
|
|
||||||
const char* endOfWord;
|
|
||||||
while ((endOfWord = strchr(startOfWord, ' ')))
|
|
||||||
{
|
{
|
||||||
extensionSet.insert(std::string(startOfWord, endOfWord));
|
extensionSet.insert(std::string(startOfWord,endOfWord));
|
||||||
startOfWord = endOfWord+1;
|
startOfWord = endOfWord+1;
|
||||||
}
|
}
|
||||||
if (*startOfWord != 0) extensionSet.insert(std::string(startOfWord));
|
if (*startOfWord!=0) extensionSet.insert(std::string(startOfWord));
|
||||||
}
|
|
||||||
|
#if defined(WIN32)
|
||||||
#endif
|
|
||||||
|
// add WGL extensions to the list
|
||||||
osg::notify(INFO)<<"OpenGL extensions supported by installed OpenGL drivers are:"<<std::endl;
|
|
||||||
for(ExtensionSet::iterator itr=extensionSet.begin();
|
typedef const char* WINAPI WGLGETEXTENSIONSSTRINGARB(HDC);
|
||||||
itr!=extensionSet.end();
|
WGLGETEXTENSIONSSTRINGARB* wglGetExtensionsStringARB =
|
||||||
++itr)
|
(WGLGETEXTENSIONSSTRINGARB*)getGLExtensionFuncPtr("wglGetExtensionsStringARB");
|
||||||
{
|
|
||||||
osg::notify(INFO)<<" "<<*itr<<std::endl;
|
typedef const char* WINAPI WGLGETEXTENSIONSSTRINGEXT();
|
||||||
|
WGLGETEXTENSIONSSTRINGEXT* wglGetExtensionsStringEXT =
|
||||||
|
(WGLGETEXTENSIONSSTRINGEXT*)getGLExtensionFuncPtr("wglGetExtensionsStringEXT");
|
||||||
|
|
||||||
|
const char* wglextensions = 0;
|
||||||
|
|
||||||
|
if (wglGetExtensionsStringARB)
|
||||||
|
{
|
||||||
|
HDC dc = wglGetCurrentDC();
|
||||||
|
wglextensions = wglGetExtensionsStringARB(dc);
|
||||||
|
}
|
||||||
|
else if (wglGetExtensionsStringEXT)
|
||||||
|
{
|
||||||
|
wglextensions = wglGetExtensionsStringEXT();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wglextensions)
|
||||||
|
{
|
||||||
|
const char* startOfWord = wglextensions;
|
||||||
|
const char* endOfWord;
|
||||||
|
while ((endOfWord = strchr(startOfWord, ' ')))
|
||||||
|
{
|
||||||
|
extensionSet.insert(std::string(startOfWord, endOfWord));
|
||||||
|
startOfWord = endOfWord+1;
|
||||||
|
}
|
||||||
|
if (*startOfWord != 0) extensionSet.insert(std::string(startOfWord));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
osg::notify(INFO)<<"OpenGL extensions supported by installed OpenGL drivers are:"<<std::endl;
|
||||||
|
for(ExtensionSet::iterator itr=extensionSet.begin();
|
||||||
|
itr!=extensionSet.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
osg::notify(INFO)<<" "<<*itr<<std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// true if extension found in extensionSet.
|
||||||
|
result = extensionSet.find(extension)!=extensionSet.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// true if extension found in extensionSet.
|
|
||||||
bool result = extensionSet.find(extension)!=extensionSet.end();
|
|
||||||
|
|
||||||
// now see if extension is in the extension disabled list
|
// now see if extension is in the extension disabled list
|
||||||
bool extensionDisabled = false;
|
bool extensionDisabled = false;
|
||||||
if (result)
|
if (result)
|
||||||
|
@ -1639,30 +1639,32 @@ void Texture::Extensions::setupGLExtensions(unsigned int contextID)
|
|||||||
const char* renderer = (const char*) glGetString(GL_RENDERER);
|
const char* renderer = (const char*) glGetString(GL_RENDERER);
|
||||||
std::string rendererString(renderer ? renderer : "");
|
std::string rendererString(renderer ? renderer : "");
|
||||||
|
|
||||||
_isMultiTexturingSupported = ( glVersion >= 1.3 ) ||
|
_isMultiTexturingSupported = isGLExtensionOrVersionSupported( contextID,"GL_ARB_multitexture", 1.3) ||
|
||||||
isGLExtensionSupported(contextID,"GL_ARB_multitexture") ||
|
isGLExtensionOrVersionSupported(contextID,"GL_EXT_multitexture", 1.3);
|
||||||
isGLExtensionSupported(contextID,"GL_EXT_multitexture");
|
|
||||||
_isTextureFilterAnisotropicSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_filter_anisotropic");
|
_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");
|
_isTextureCompressionS3TCSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_compression_s3tc");
|
||||||
_isTextureMirroredRepeatSupported = ( glVersion >= 1.4 ) ||
|
|
||||||
isGLExtensionSupported(contextID,"GL_IBM_texture_mirrored_repeat") ||
|
_isTextureMirroredRepeatSupported = isGLExtensionOrVersionSupported(contextID,"GL_IBM_texture_mirrored_repeat", 1.4) ||
|
||||||
isGLExtensionSupported(contextID,"GL_ARB_texture_mirrored_repeat");
|
isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_mirrored_repeat", 1.4);
|
||||||
_isTextureEdgeClampSupported = ( glVersion >= 1.2 ) ||
|
|
||||||
isGLExtensionSupported(contextID,"GL_EXT_texture_edge_clamp") ||
|
_isTextureEdgeClampSupported = isGLExtensionOrVersionSupported(contextID,"GL_EXT_texture_edge_clamp", 1.2) ||
|
||||||
isGLExtensionSupported(contextID,"GL_SGIS_texture_edge_clamp");
|
isGLExtensionOrVersionSupported(contextID,"GL_SGIS_texture_edge_clamp", 1.2);
|
||||||
_isTextureBorderClampSupported = ( glVersion >= 1.3 ) ||
|
|
||||||
isGLExtensionSupported(contextID,"GL_ARB_texture_border_clamp");
|
_isTextureBorderClampSupported = isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_border_clamp", 1.3);
|
||||||
_isGenerateMipMapSupported = (strncmp((const char*)glGetString(GL_VERSION),"1.4",3)>=0) ||
|
|
||||||
isGLExtensionSupported(contextID,"GL_SGIS_generate_mipmap");
|
_isGenerateMipMapSupported = isGLExtensionOrVersionSupported(contextID,"GL_SGIS_generate_mipmap", 1.4);
|
||||||
|
|
||||||
_isShadowSupported = isGLExtensionSupported(contextID,"GL_ARB_shadow");
|
_isShadowSupported = isGLExtensionSupported(contextID,"GL_ARB_shadow");
|
||||||
|
|
||||||
_isShadowAmbientSupported = isGLExtensionSupported(contextID,"GL_ARB_shadow_ambient");
|
_isShadowAmbientSupported = isGLExtensionSupported(contextID,"GL_ARB_shadow_ambient");
|
||||||
|
|
||||||
_isClientStorageSupported = isGLExtensionSupported(contextID,"GL_APPLE_client_storage");
|
_isClientStorageSupported = isGLExtensionSupported(contextID,"GL_APPLE_client_storage");
|
||||||
|
|
||||||
_isNonPowerOfTwoTextureNonMipMappedSupported = ( glVersion >= 2.0 ) ||
|
_isNonPowerOfTwoTextureNonMipMappedSupported = isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_non_power_of_two", 2.0);
|
||||||
isGLExtensionSupported(contextID,"GL_ARB_texture_non_power_of_two");
|
|
||||||
|
|
||||||
_isNonPowerOfTwoTextureMipMappedSupported = _isNonPowerOfTwoTextureNonMipMappedSupported;
|
_isNonPowerOfTwoTextureMipMappedSupported = _isNonPowerOfTwoTextureNonMipMappedSupported;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user