From bac20de0499c4e277ee8824689447a696d0de3ad Mon Sep 17 00:00:00 2001 From: Matthias Bentrup Date: Wed, 4 Feb 2015 15:44:01 +0100 Subject: [PATCH] Get GL extension strings via glGetStringi() if GL version is >= 3.0. --- auto/src/glew_init_glext.c | 51 ++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/auto/src/glew_init_glext.c b/auto/src/glew_init_glext.c index 103e551..938a0cc 100644 --- a/auto/src/glew_init_glext.c +++ b/auto/src/glew_init_glext.c @@ -1,23 +1,48 @@ - /* query opengl extensions string */ - extStart = glGetString(GL_EXTENSIONS); - if (extStart == 0) - extStart = (const GLubyte*)""; - extEnd = extStart + _glewStrLen(extStart); - - while (extStart < extEnd) + /* query opengl extensions string(s) */ + if(GLEW_VERSION_3_0) { - GLuint len = _glewStrCLen(extStart, ' '); - struct initflag *ptr = in_word_set(extStart, len); + GLuint len; + struct initflag *ptr; - if (ptr != NULL && ptr->flag != NULL) { + glGetIntegerv(GL_NUM_EXTENSIONS, &numExts); + for (ext = 0; ext < numExts; ext++) + { + extStart = glGetStringi(GL_EXTENSIONS, ext); + len = _glewStrLen(extStart); + ptr = in_word_set(extStart, len); + + if (ptr != NULL && ptr->flag != NULL) { #ifdef GLEW_MX - *(GLboolean *)((char *)ctx + (size_t)(ptr->flag)) = GL_TRUE; + *(GLboolean *)((char *)ctx + (size_t)(ptr->flag)) = GL_TRUE; #else - *ptr->flag = GL_TRUE; + *ptr->flag = GL_TRUE; #endif + } + extStart += len + 1; + } + } + else + { + extStart = glGetString(GL_EXTENSIONS); + if (extStart == 0) + extStart = (const GLubyte*)""; + extEnd = extStart + _glewStrLen(extStart); + + while (extStart < extEnd) + { + GLuint len = _glewStrCLen(extStart, ' '); + struct initflag *ptr = in_word_set(extStart, len); + + if (ptr != NULL && ptr->flag != NULL) { +#ifdef GLEW_MX + *(GLboolean *)((char *)ctx + (size_t)(ptr->flag)) = GL_TRUE; +#else + *ptr->flag = GL_TRUE; +#endif + } + extStart += len + 1; } - extStart += len + 1; } /* initialize extensions */