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