diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index ee8bbc420..d95de7e89 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -91,18 +91,53 @@ bool osg::isGLExtensionOrVersionSupported(unsigned int contextID, const char *ex 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) + if( osg::getGLVersionNumber() >= 3.0 ) { - extensionSet.insert(std::string(startOfWord,endOfWord)); - startOfWord = endOfWord+1; + // OpenGL 3.0 adds the concept of indexed strings and + // deprecates calls to glGetString( GL_EXTENSIONS ), which + // will now generate GL_INVALID_ENUM. + + // Get extensions using new indexed string interface. + + typedef const GLubyte * APIENTRY PFNGLGETSTRINGIPROC( GLenum, GLuint ); + PFNGLGETSTRINGIPROC* glGetStringi = 0; + setGLExtensionFuncPtr( glGetStringi, "glGetStringi"); + + if( glGetStringi != NULL ) + { + # ifndef GL_NUM_EXTENSIONS + # define GL_NUM_EXTENSIONS 0x821D + # endif + GLint numExt; + glGetIntegerv( GL_NUM_EXTENSIONS, &numExt ); + int idx; + for( idx=0; idx