Refactor graphics init to pass in the context
This commit is contained in:
parent
1db1187b15
commit
190d393cd2
3 changed files with 7 additions and 9 deletions
|
@ -172,7 +172,7 @@ struct GeneralInitOperation : public GraphicsContextOperation
|
|||
|
||||
/** Initializes GUI.
|
||||
* Returns true when done, false when still busy (call again). */
|
||||
bool guiInit()
|
||||
bool guiInit(osg::GraphicsContext* gc)
|
||||
{
|
||||
static osg::ref_ptr<GeneralInitOperation> genOp;
|
||||
static bool didInit = false;
|
||||
|
@ -187,11 +187,6 @@ bool guiInit()
|
|||
// XXX Perhaps all this graphics initialization code should be
|
||||
// moved to renderer.cxx?
|
||||
genOp = new GeneralInitOperation;
|
||||
osg::Camera* guiCamera = getGUICamera(CameraGroup::getDefault());
|
||||
WindowSystemAdapter* wsa = WindowSystemAdapter::getWSA();
|
||||
osg::GraphicsContext* gc = 0;
|
||||
if (guiCamera)
|
||||
gc = guiCamera->getGraphicsContext();
|
||||
if (gc) {
|
||||
gc->add(genOp.get());
|
||||
#if defined(HAVE_PUI)
|
||||
|
@ -199,6 +194,7 @@ bool guiInit()
|
|||
gc->add(initOp.get());
|
||||
#endif
|
||||
} else {
|
||||
WindowSystemAdapter* wsa = WindowSystemAdapter::getWSA();
|
||||
wsa->windows[0]->gc->add(genOp.get());
|
||||
}
|
||||
return false; // not ready yet
|
||||
|
|
|
@ -40,7 +40,8 @@ namespace osg
|
|||
class GraphicsContext;
|
||||
}
|
||||
// gui.cxx
|
||||
extern bool guiInit();
|
||||
extern bool guiInit(osg::GraphicsContext* gc = nullptr);
|
||||
|
||||
extern bool openBrowser(const std::string& address);
|
||||
extern void mkDialog(const char *txt);
|
||||
extern void guiErrorMessage(const char *txt);
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include <Scenery/scenery.hxx>
|
||||
#include <Sound/soundmanager.hxx>
|
||||
#include <Time/TimeManager.hxx>
|
||||
#include <Viewer/CameraGroup.hxx>
|
||||
#include <Viewer/GraphicsPresets.hxx>
|
||||
#include <Viewer/WindowSystemAdapter.hxx>
|
||||
#include <Viewer/renderer.hxx>
|
||||
|
@ -313,8 +314,8 @@ static void fgIdleFunction ( void ) {
|
|||
// splash screen up and running right away.
|
||||
|
||||
if ( idle_state == 0 ) {
|
||||
if (guiInit())
|
||||
{
|
||||
auto camera = flightgear::getGUICamera(flightgear::CameraGroup::getDefault());
|
||||
if (guiInit(camera->getGraphicsContext())) {
|
||||
checkOpenGLVersion();
|
||||
fgSetVideoOptions();
|
||||
idle_state+=2;
|
||||
|
|
Loading…
Reference in a new issue