Commit f6b94c1a authored by Jan Möbius's avatar Jan Möbius

Merge branch 'check_glcontext_on_startup' into 'master'

Check glcontext on startup

See merge request !94
parents adca7cc8 9e50d907
......@@ -562,7 +562,39 @@ int main(int argc, char **argv)
surface->create();
//make the globally shared OpenGLContext current
QOpenGLContext::globalShareContext()->makeCurrent(surface);
QOpenGLContext::globalShareContext()->makeCurrent(surface);
// The opengl surface properties that have actually been applied
// (does not necessarily match the requested properties)
QSurfaceFormat actuallyAppliedFormat = QOpenGLContext::globalShareContext()->format();
auto curVersion = actuallyAppliedFormat.version();
// Check whether the actually applied OpenGL context matches the requested one.
// If not, print some error to the console
if(curVersion.first != version.first ||
curVersion.second != version.second ||
format.profile() != actuallyAppliedFormat.profile())
{
auto reqProfileString = "None";
if(format.profile() == QSurfaceFormat::CoreProfile)
reqProfileString = "Core";
else if(format.profile() == QSurfaceFormat::CompatibilityProfile)
reqProfileString = "Compat";
auto curProfileString = "None";
if(actuallyAppliedFormat.profile() == QSurfaceFormat::CoreProfile)
curProfileString = "Core";
else if(actuallyAppliedFormat.profile() == QSurfaceFormat::CompatibilityProfile)
curProfileString = "Compat";
std::cerr << "Warning! OpenGL version " << version.first << "."
<< version.second << " (" << reqProfileString << ")"
<< " was requested, but version " << curVersion.first << "."
<< curVersion.second << " (" << curProfileString << ")"
<< " was applied." << std::endl;
std::cerr << "Please consider setting supported OpenGL version and context in the Options dialog." << std::endl;
}
if ( !QGLFormat::hasOpenGL() ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment