Commit 3b12813a authored by Kersten Schuster's avatar Kersten Schuster

Check whether the OpenGL context matches the one that was requested via...

Check whether the OpenGL context matches the one that was requested via settings. If not, print a warning.
parent 1abf8d5a
......@@ -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