Fix OpenGL extensions not loading

This commit is contained in:
hobby8 2018-10-06 22:49:48 +03:00 committed by Lukas Dürrenberger
parent 53d8f66d43
commit 7e40f80f52

View File

@ -218,10 +218,12 @@ namespace
extensions.clear(); extensions.clear();
// Check whether a >= 3.0 context is available // Check whether a >= 3.0 context is available
glGetStringiFuncType glGetStringiFunc = NULL;
glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(sf::priv::GlContext::getFunction("glGetStringi"));
int majorVersion = 0; int majorVersion = 0;
glGetIntegerv(GL_MAJOR_VERSION, &majorVersion); glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
if (glGetError() == GL_INVALID_ENUM) if (glGetError() == GL_INVALID_ENUM || !glGetStringiFunc)
{ {
// Try to load the < 3.0 way // Try to load the < 3.0 way
const char* extensionString = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); const char* extensionString = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
@ -240,11 +242,6 @@ namespace
else else
{ {
// Try to load the >= 3.0 way // Try to load the >= 3.0 way
glGetStringiFuncType glGetStringiFunc = NULL;
glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(sf::priv::GlContext::getFunction("glGetStringi"));
if (glGetStringiFunc)
{
int numExtensions = 0; int numExtensions = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
@ -259,7 +256,6 @@ namespace
} }
} }
} }
}
// Helper to parse OpenGL version strings // Helper to parse OpenGL version strings
bool parseVersionString(const char* version, const char* prefix, unsigned int &major, unsigned int &minor) bool parseVersionString(const char* version, const char* prefix, unsigned int &major, unsigned int &minor)