]> git.tdb.fi Git - libs/gl.git/commitdiff
Use indexed string query to get extensions on OpenGL 3.0 and above
authorMikko Rasa <tdb@tdb.fi>
Wed, 2 Nov 2016 22:23:08 +0000 (00:23 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 2 Nov 2016 22:35:26 +0000 (00:35 +0200)
source/extension.cpp

index e233ee0012eb60563366d7061acf682ae92f96b9..2183a965027d85550447fc77589f419789db890d 100644 (file)
@@ -75,10 +75,22 @@ bool is_supported(const string &ext)
 
        if(!init_done)
        {
-               if(const char *gl_ext = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)))
+               if(get_gl_api()==OPENGL && get_gl_version()>=Version(3, 0))
                {
-                       vector<string> exts = split(gl_ext);
-                       extensions.insert(exts.begin(), exts.end());
+                       typedef GLubyte *(APIENTRY *FPtr_glGetStringi)(GLenum, GLuint);
+                       FPtr_glGetStringi glGetStringi = reinterpret_cast<FPtr_glGetStringi>(get_proc_address("glGetStringi"));
+                       int n_extensions;
+                       glGetIntegerv(GL_NUM_EXTENSIONS, &n_extensions);
+                       for(int i=0; i<n_extensions; ++i)
+                               extensions.insert(reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i)));
+               }
+               else
+               {
+                       if(const char *gl_ext = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)))
+                       {
+                               vector<string> exts = split(gl_ext);
+                               extensions.insert(exts.begin(), exts.end());
+                       }
                }
 
                if(const char *renderer_ptr = reinterpret_cast<const char *>(glGetString(GL_RENDERER)))