From: Mikko Rasa Date: Wed, 2 Nov 2016 22:23:08 +0000 (+0200) Subject: Use indexed string query to get extensions on OpenGL 3.0 and above X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=bdde5adcb78836c4d75196546059ae827cf3af9e;p=libs%2Fgl.git Use indexed string query to get extensions on OpenGL 3.0 and above --- diff --git a/source/extension.cpp b/source/extension.cpp index e233ee00..2183a965 100644 --- a/source/extension.cpp +++ b/source/extension.cpp @@ -75,10 +75,22 @@ bool is_supported(const string &ext) if(!init_done) { - if(const char *gl_ext = reinterpret_cast(glGetString(GL_EXTENSIONS))) + if(get_gl_api()==OPENGL && get_gl_version()>=Version(3, 0)) { - vector exts = split(gl_ext); - extensions.insert(exts.begin(), exts.end()); + typedef GLubyte *(APIENTRY *FPtr_glGetStringi)(GLenum, GLuint); + FPtr_glGetStringi glGetStringi = reinterpret_cast(get_proc_address("glGetStringi")); + int n_extensions; + glGetIntegerv(GL_NUM_EXTENSIONS, &n_extensions); + for(int i=0; i(glGetStringi(GL_EXTENSIONS, i))); + } + else + { + if(const char *gl_ext = reinterpret_cast(glGetString(GL_EXTENSIONS))) + { + vector exts = split(gl_ext); + extensions.insert(exts.begin(), exts.end()); + } } if(const char *renderer_ptr = reinterpret_cast(glGetString(GL_RENDERER)))