Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OpenGL extensions not loading #1543

Merged
merged 1 commit into from Jan 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 9 additions & 13 deletions src/SFML/Window/GlContext.cpp
Expand Up @@ -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));
Expand All @@ -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);
}
}
}
Expand Down