From 7e40f80f52ea0ba35ca6e4ffd40a6fc8c0fa7536 Mon Sep 17 00:00:00 2001 From: hobby8 Date: Sat, 6 Oct 2018 22:49:48 +0300 Subject: [PATCH] Fix OpenGL extensions not loading --- src/SFML/Window/GlContext.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) 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); } } }