diff --git a/src/SFML/Window/GlContext.cpp b/src/SFML/Window/GlContext.cpp index 39dc9339..fd3805d4 100644 --- a/src/SFML/Window/GlContext.cpp +++ b/src/SFML/Window/GlContext.cpp @@ -218,10 +218,12 @@ namespace extensions.clear(); // Check whether a >= 3.0 context is available + glGetStringiFuncType glGetStringiFunc = NULL; + glGetStringiFunc = reinterpret_cast(sf::priv::GlContext::getFunction("glGetStringi")); int majorVersion = 0; glGetIntegerv(GL_MAJOR_VERSION, &majorVersion); - if (glGetError() == GL_INVALID_ENUM) + if (glGetError() == GL_INVALID_ENUM || !glGetStringiFunc) { // Try to load the < 3.0 way const char* extensionString = reinterpret_cast(glGetString(GL_EXTENSIONS)); @@ -240,22 +242,16 @@ namespace else { // Try to load the >= 3.0 way - glGetStringiFuncType glGetStringiFunc = NULL; - glGetStringiFunc = reinterpret_cast(sf::priv::GlContext::getFunction("glGetStringi")); + int numExtensions = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); - if (glGetStringiFunc) + if (numExtensions) { - int numExtensions = 0; - glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); - - if (numExtensions) + for (unsigned int i = 0; i < static_cast(numExtensions); ++i) { - for (unsigned int i = 0; i < static_cast(numExtensions); ++i) - { - const char* extensionString = reinterpret_cast(glGetStringiFunc(GL_EXTENSIONS, i)); + const char* extensionString = reinterpret_cast(glGetStringiFunc(GL_EXTENSIONS, i)); - extensions.push_back(extensionString); - } + extensions.push_back(extensionString); } } }