From 190d393cd28275e39bd0c9a664325be449f8ef56 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 22 Sep 2022 10:49:22 +0300 Subject: [PATCH] Refactor graphics init to pass in the context --- src/GUI/gui.cxx | 8 ++------ src/GUI/gui.h | 3 ++- src/Main/main.cxx | 5 +++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/GUI/gui.cxx b/src/GUI/gui.cxx index 0e9199562..9ba51ad14 100644 --- a/src/GUI/gui.cxx +++ b/src/GUI/gui.cxx @@ -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 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 diff --git a/src/GUI/gui.h b/src/GUI/gui.h index f3d9915b1..4400bd49c 100644 --- a/src/GUI/gui.h +++ b/src/GUI/gui.h @@ -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); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 2cbf2f4e5..7b8e7850b 100755 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -60,6 +60,7 @@ #include #include #include