| 94 | | const char* extensions = (const char*)glGetString(GL_EXTENSIONS); |
| 95 | | if (extensions==NULL) return false; |
| 96 | | |
| 97 | | // insert the ' ' delimiated extensions words into the extensionSet. |
| 98 | | const char *startOfWord = extensions; |
| 99 | | const char *endOfWord; |
| 100 | | while ((endOfWord = strchr(startOfWord,' '))!=NULL) |
| 101 | | { |
| 102 | | extensionSet.insert(std::string(startOfWord,endOfWord)); |
| 103 | | startOfWord = endOfWord+1; |
| 104 | | } |
| 105 | | if (*startOfWord!=0) extensionSet.insert(std::string(startOfWord)); |
| | 94 | if( osg::getGLVersionNumber() >= 3.0 ) |
| | 95 | { |
| | 96 | // OpenGL 3.0 adds the concept of indexed strings and |
| | 97 | // deprecates calls to glGetString( GL_EXTENSIONS ), which |
| | 98 | // will now generate GL_INVALID_ENUM. |
| | 99 | |
| | 100 | // Get extensions using new indexed string interface. |
| | 101 | |
| | 102 | typedef const GLubyte * APIENTRY PFNGLGETSTRINGIPROC( GLenum, GLuint ); |
| | 103 | PFNGLGETSTRINGIPROC* glGetStringi = 0; |
| | 104 | setGLExtensionFuncPtr( glGetStringi, "glGetStringi"); |
| | 105 | |
| | 106 | if( glGetStringi != NULL ) |
| | 107 | { |
| | 108 | # ifndef GL_NUM_EXTENSIONS |
| | 109 | # define GL_NUM_EXTENSIONS 0x821D |
| | 110 | # endif |
| | 111 | GLint numExt; |
| | 112 | glGetIntegerv( GL_NUM_EXTENSIONS, &numExt ); |
| | 113 | int idx; |
| | 114 | for( idx=0; idx<numExt; idx++ ) |
| | 115 | { |
| | 116 | extensionSet.insert( std::string( (char*)( glGetStringi( GL_EXTENSIONS, idx ) ) ) ); |
| | 117 | } |
| | 118 | } |
| | 119 | else |
| | 120 | { |
| | 121 | osg::notify( osg::WARN ) << "isGLExtensionOrVersionSupported: Can't obtain glGetStringi function pointer." << std::endl; |
| | 122 | } |
| | 123 | } |
| | 124 | else |
| | 125 | { |
| | 126 | // Get extensions using GL1/2 interface. |
| | 127 | |
| | 128 | const char* extensions = (const char*)glGetString(GL_EXTENSIONS); |
| | 129 | if (extensions==NULL) return false; |
| | 130 | |
| | 131 | // insert the ' ' delimiated extensions words into the extensionSet. |
| | 132 | const char *startOfWord = extensions; |
| | 133 | const char *endOfWord; |
| | 134 | while ((endOfWord = strchr(startOfWord,' '))!=NULL) |
| | 135 | { |
| | 136 | extensionSet.insert(std::string(startOfWord,endOfWord)); |
| | 137 | startOfWord = endOfWord+1; |
| | 138 | } |
| | 139 | if (*startOfWord!=0) extensionSet.insert(std::string(startOfWord)); |
| | 140 | } |