From 50ab301bd8646e56e22b8465ad56d74c59eee3cf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Apr 2016 16:23:32 +0200 Subject: [PATCH] - fixed: If we want to support pre-GL3 hardware, we may not require the presence of glGetStringi. --- src/gl/system/gl_interface.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index c09038bf8..a5dbf0533 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -66,10 +66,35 @@ static void CollectExtensions() int max = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &max); - for(int i = 0; i < max; i++) + if (0 == max) { - extension = (const char*)glGetStringi(GL_EXTENSIONS, i); - m_Extensions.Push(FString(extension)); + // Try old method to collect extensions + const char *supported = (char *)glGetString(GL_EXTENSIONS); + + if (nullptr != supported) + { + char *extensions = new char[strlen(supported) + 1]; + strcpy(extensions, supported); + + char *extension = strtok(extensions, " "); + + while (extension) + { + m_Extensions.Push(FString(extension)); + extension = strtok(nullptr, " "); + } + + delete [] extensions; + } + } + else + { + // Use modern method to collect extensions + for (int i = 0; i < max; i++) + { + extension = (const char*)glGetStringi(GL_EXTENSIONS, i); + m_Extensions.Push(FString(extension)); + } } }