From 0e29cd6971d3500b9b8e58e3a304958d95f3bf19 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 26 Feb 2010 09:48:22 +0000 Subject: [PATCH] From Paul Martz, "Summary: GL3 deprecates "glGetString(GL_EXTENSIONS)". In GL3, individual extension strings are queried by looping over GL_NUM_EXTENSIONS and calling "glGetStringi(GL_EXTENSIONS,)". The fix is basically as follows: if( GL3 ) Query indexed extension strings. else Query the old way. The "else" branch is re-indented but otherwise shouldn't contain any changes." --- src/osg/GLExtensions.cpp | 55 ++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 10 deletions(-) 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