From bdde5adcb78836c4d75196546059ae827cf3af9e Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 3 Nov 2016 00:23:08 +0200 Subject: [PATCH] Use indexed string query to get extensions on OpenGL 3.0 and above --- source/extension.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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))) -- 2.45.2