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();
// Check whether a >= 3.0 context is available
glGetStringiFuncType glGetStringiFunc = NULL;
glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(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<const char*>(glGetString(GL_EXTENSIONS));
@ -240,22 +242,16 @@ namespace
else
{
// Try to load the >= 3.0 way
glGetStringiFuncType glGetStringiFunc = NULL;
glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(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<unsigned int>(numExtensions); ++i)
{
for (unsigned int i = 0; i < static_cast<unsigned int>(numExtensions); ++i)
{
const char* extensionString = reinterpret_cast<const char*>(glGetStringiFunc(GL_EXTENSIONS, i));
const char* extensionString = reinterpret_cast<const char*>(glGetStringiFunc(GL_EXTENSIONS, i));
extensions.push_back(extensionString);
}
extensions.push_back(extensionString);
}
}
}