From f1aac50e30c261e684f62e29374fed576972ccda Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 22 Dec 2014 00:29:59 +0200 Subject: [PATCH] Fix glewGetExtension on core context --- auto/src/glew_init_gl.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/auto/src/glew_init_gl.c b/auto/src/glew_init_gl.c index 40a871a..380282a 100644 --- a/auto/src/glew_init_gl.c +++ b/auto/src/glew_init_gl.c @@ -5,8 +5,22 @@ GLboolean GLEWAPIENTRY glewGetExtension (const char* name) const GLubyte* start; const GLubyte* end; start = (const GLubyte*)glGetString(GL_EXTENSIONS); - if (start == 0) + if (start == 0) { + /* no extension string, we're probably on a core context + query extensions one at a time */ + GLint numExtensions = 0; + int i; + glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); + /* glewContextInit should have initialized glGetStringi for us */ + for (i = 0; i < numExtensions; i++) { + const GLubyte* extName = glGetStringi(GL_EXTENSIONS, i); + GLuint len = _glewStrLen(extName); + if (_glewStrSame((const GLubyte*) name, extName, len)) { + return GL_TRUE; + } + } return GL_FALSE; + } end = start + _glewStrLen(start); return _glewSearchExtension(name, start, end); }