1
0
Fork 0

Rework OpenGL check to avoid potential problems

A few versions of the Windows Intel drivers seem to crash while 
performing the OpenGL check; re-order the code to try and prevent
this.

Sentry-Id: FLIGHTGEAR-K7R
This commit is contained in:
James Turner 2021-02-24 11:41:33 +00:00
parent 335d0003cc
commit 2178de9d0d

View file

@ -276,26 +276,33 @@ OpenGLStatus checkForWorkingOpenGL()
return OpenGLStatus::Unknown;
}
// from here on, we need to ensure orderly cleanup or some drivers
// crash. So we can't early return.
OpenGLStatus result = OpenGLStatus::Unknown;
QOffscreenSurface offSurface;
offSurface.setFormat(ctx.format()); // ensure it's compatible
offSurface.create();
if (!ctx.makeCurrent(&offSurface)) {
return OpenGLStatus::Unknown;
}
std::string renderer = (char*)glGetString(GL_RENDERER);
if (renderer == "GDI Generic") {
flightgear::addSentryBreadcrumb("Detected GDI generic renderer", "info");
return OpenGLStatus::GDIGeneric;
} else if (simgear::strutils::starts_with(renderer, "Intel")) {
if (ctx.format().majorVersion() < 2) {
flightgear::addSentryBreadcrumb("Detected Intel < 2.1 renderer", "info");
return OpenGLStatus::Intel14;
if (ctx.makeCurrent(&offSurface)) {
result = OpenGLStatus::OpenGL21;
std::string renderer = (char*)glGetString(GL_RENDERER);
if (renderer == "GDI Generic") {
flightgear::addSentryBreadcrumb("Detected GDI generic renderer", "info");
result = OpenGLStatus::GDIGeneric;
} else if (simgear::strutils::starts_with(renderer, "Intel")) {
if (ctx.format().majorVersion() < 2) {
flightgear::addSentryBreadcrumb("Detected Intel < 2.1 renderer", "info");
result = OpenGLStatus::Intel14;
}
}
// not worried about 2.0
// ensure the context is no longer current on the offscreen
ctx.doneCurrent();
}
return OpenGLStatus::OpenGL21;
offSurface.destroy();
return result;
}
} // of anonymous namespace