1
0
Fork 0

Add a fatal message when GraphicsContext creation fails

Avoids crashing shortly afterwards with no window, and might help a
few users realise their problem is outdated graphics drivers.
This commit is contained in:
Automatic Release Builder 2020-12-06 18:48:49 +00:00 committed by James Turner
parent e7801a65b3
commit bab80744f6

View file

@ -21,6 +21,8 @@
#include <Main/fg_props.hxx>
#include <osg/Version>
#include <GUI/MessageBox.hxx>
#include <sstream>
#include <limits>
@ -360,21 +362,28 @@ GraphicsWindow* WindowBuilder::getDefaultWindow()
= WindowSystemAdapter::getWSA()->findWindow(defaultWindowName);
if (defaultWindow)
return defaultWindow;
// create if it, if necessary
GraphicsContext::Traits* traits
= new GraphicsContext::Traits(*defaultTraits);
traits->windowName = "FlightGear";
setMacPoseAsStandaloneApp(traits);
// this may be the point, where we discover OpenGL is broken on the
// system.
GraphicsContext* gc = GraphicsContext::createGraphicsContext(traits);
if (gc) {
defaultWindow = WindowSystemAdapter::getWSA()
->registerWindow(gc, defaultWindowName);
return defaultWindow;
} else {
SG_LOG(SG_VIEW, SG_ALERT, "getDefaultWindow: failed to create GraphicsContext");
return 0;
if (!gc) {
flightgear::fatalMessageBoxThenExit("Unable to create window",
"FlightGear was unable to create a window supporting 3D rendering (OpenGL). "
"This is normally due to outdated graphics drivers, please check if updates are available. ",
"Depending on your OS and graphics chipset, updates might come from AMD, nVidia or Intel.");
return nullptr; // unreachable anyway
}
defaultWindow = WindowSystemAdapter::getWSA()->registerWindow(gc, defaultWindowName);
return defaultWindow;
}
void WindowBuilder::setPoseAsStandaloneApp(bool b)