diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index d7d4c60fd5..c41a94245f 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -221,7 +221,7 @@ void mainInitFunc(GLFWwindow*) { LTRACE("main::mainInitFunc(begin)"); LDEBUG("Initializing OpenSpace Engine started"); - global::openSpaceEngine.initialize(); + global::openSpaceEngine->initialize(); LDEBUG("Initializing OpenSpace Engine finished"); { @@ -247,7 +247,7 @@ void mainInitFunc(GLFWwindow*) { currentViewport = currentWindow->viewports().front().get(); LDEBUG("Initializing OpenGL in OpenSpace Engine started"); - global::openSpaceEngine.initializeGL(); + global::openSpaceEngine->initializeGL(); LDEBUG("Initializing OpenGL in OpenSpace Engine finished"); @@ -325,7 +325,7 @@ void mainInitFunc(GLFWwindow*) { // Screenshots // std::string screenshotPath = "${SCREENSHOTS}"; - if (global::configuration.shouldUseScreenshotDate) { + if (global::configuration->shouldUseScreenshotDate) { std::time_t now = std::time(nullptr); std::tm* nowTime = std::localtime(&now); char mbstr[128]; @@ -351,7 +351,7 @@ void mainPreSyncFunc() { LTRACE("main::mainPreSyncFunc(begin)"); try { - global::openSpaceEngine.preSynchronization(); + global::openSpaceEngine->preSynchronization(); } catch (const ghoul::RuntimeError& e) { LFATALC(e.component, e.message); @@ -364,7 +364,7 @@ void mainPreSyncFunc() { for (int i = GLFW_JOYSTICK_1; i <= GLFW_JOYSTICK_LAST; ++i) { ZoneScopedN("Joystick state"); - JoystickInputState& state = global::joystickInputStates[i]; + JoystickInputState& state = global::joystickInputStates->at(i); int present = glfwJoystickPresent(i); if (present == GLFW_FALSE) { @@ -446,7 +446,7 @@ void mainPostSyncPreDrawFunc() { #endif // OPENSPACE_HAS_NVTOOLS LTRACE("main::postSynchronizationPreDraw(begin)"); - global::openSpaceEngine.postSynchronizationPreDraw(); + global::openSpaceEngine->postSynchronizationPreDraw(); #ifdef OPENVR_SUPPORT if (FirstOpenVRWindow) { @@ -515,7 +515,7 @@ void mainRenderFunc(const sgct::RenderData& data) { ); currentModelMatrix = modelMatrix; currentModelViewProjectionMatrix = modelMatrix * viewMatrix * projectionMatrix; - global::openSpaceEngine.render(modelMatrix, viewMatrix, projectionMatrix); + global::openSpaceEngine->render(modelMatrix, viewMatrix, projectionMatrix); } catch (const ghoul::RuntimeError& e) { LERRORC(e.component, e.message); @@ -538,7 +538,7 @@ void mainDraw2DFunc(const sgct::RenderData& data) { currentFrustumMode = data.frustumMode; try { - global::openSpaceEngine.drawOverlays(); + global::openSpaceEngine->drawOverlays(); } catch (const ghoul::RuntimeError& e) { LERRORC(e.component, e.message); @@ -565,7 +565,7 @@ void mainPostDrawFunc() { } #endif // OPENVR_SUPPORT - global::openSpaceEngine.postDraw(); + global::openSpaceEngine->postDraw(); #ifdef OPENSPACE_HAS_SPOUT for (const SpoutWindow& w : SpoutWindows) { @@ -609,7 +609,7 @@ void mainKeyboardCallback(sgct::Key key, sgct::Modifier modifiers, sgct::Action const openspace::Key k = openspace::Key(key); const KeyModifier m = KeyModifier(modifiers); const KeyAction a = KeyAction(action); - global::openSpaceEngine.keyboardCallback(k, m, a); + global::openSpaceEngine->keyboardCallback(k, m, a); LTRACE("main::mainKeyboardCallback(begin)"); } @@ -625,7 +625,7 @@ void mainMouseButtonCallback(sgct::MouseButton key, sgct::Modifier modifiers, const openspace::MouseButton k = openspace::MouseButton(key); const openspace::MouseAction a = openspace::MouseAction(action); const openspace::KeyModifier m = openspace::KeyModifier(modifiers); - global::openSpaceEngine.mouseButtonCallback(k, a, m); + global::openSpaceEngine->mouseButtonCallback(k, a, m); LTRACE("main::mainMouseButtonCallback(end)"); } @@ -634,7 +634,7 @@ void mainMouseButtonCallback(sgct::MouseButton key, sgct::Modifier modifiers, void mainMousePosCallback(double x, double y) { ZoneScoped - global::openSpaceEngine.mousePositionCallback(x, y); + global::openSpaceEngine->mousePositionCallback(x, y); } @@ -643,7 +643,7 @@ void mainMouseScrollCallback(double posX, double posY) { ZoneScoped LTRACE("main::mainMouseScrollCallback(begin"); - global::openSpaceEngine.mouseScrollWheelCallback(posX, posY); + global::openSpaceEngine->mouseScrollWheelCallback(posX, posY); LTRACE("main::mainMouseScrollCallback(end)"); } @@ -654,7 +654,7 @@ void mainCharCallback(unsigned int codepoint, int modifiers) { ZoneScoped const KeyModifier m = KeyModifier(modifiers); - global::openSpaceEngine.charCallback(codepoint, m); + global::openSpaceEngine->charCallback(codepoint, m); } @@ -663,7 +663,7 @@ std::vector mainEncodeFun() { ZoneScoped LTRACE("main::mainEncodeFun(begin)"); - std::vector data = global::openSpaceEngine.encode(); + std::vector data = global::openSpaceEngine->encode(); LTRACE("main::mainEncodeFun(end)"); return data; @@ -675,7 +675,7 @@ void mainDecodeFun(const std::vector& data, unsigned int) { ZoneScoped LTRACE("main::mainDecodeFun(begin)"); - global::openSpaceEngine.decode(data); + global::openSpaceEngine->decode(data); LTRACE("main::mainDecodeFun(end)"); } @@ -704,7 +704,7 @@ void mainLogCallback(Log::Level level, std::string_view message) { void setSgctDelegateFunctions() { - WindowDelegate& sgctDelegate = global::windowDelegate; + WindowDelegate& sgctDelegate = *global::windowDelegate; sgctDelegate.terminate = []() { Engine::instance().terminate(); }; sgctDelegate.setBarrier = [](bool enabled) { ZoneScoped @@ -959,7 +959,7 @@ std::string setWindowConfigPresetForGui(const std::string labelFromCfgFile, const std::string xmlExt, bool haveCliSGCTConfig, const std::string& sgctFunctionName) { - configuration::Configuration& config = global::configuration; + configuration::Configuration& config = *global::configuration; std::string preset; bool sgctConfigFileSpecifiedByLuaFunction = !config.sgctConfigNameInitialized.empty(); @@ -1003,12 +1003,14 @@ std::string selectedSgctProfileFromLauncher(LauncherWindow& lw, bool hasCliSGCTC else { config = "${CONFIG}/" + config + xmlExt; } - global::configuration.windowConfiguration = config; + global::configuration->windowConfiguration = config; } return config; } int main(int argc, char** argv) { + glfwInit(); + #ifdef WIN32 SetUnhandledExceptionFilter(generateMiniDump); #endif // WIN32 @@ -1031,6 +1033,7 @@ int main(int argc, char** argv) { } ghoul::initialize(); + global::create(); // Register the path of the executable, // to make it possible to find other files in the same directory. @@ -1104,7 +1107,7 @@ int main(int argc, char** argv) { // Loading configuration from disk LDEBUG("Loading configuration from disk"); - global::configuration = configuration::loadConfigurationFromFile( + *global::configuration = configuration::loadConfigurationFromFile( configurationFilePath ); // If the user requested a commandline-based configuration script that should @@ -1113,16 +1116,16 @@ int main(int argc, char** argv) { LDEBUG("Executing Lua script passed through the commandline:"); LDEBUG(commandlineArguments.configurationOverride); ghoul::lua::runScript( - global::configuration.state, + global::configuration->state, commandlineArguments.configurationOverride ); - parseLuaState(global::configuration); + parseLuaState(*global::configuration); } // Determining SGCT configuration file - LDEBUG("SGCT Configuration file: " + global::configuration.windowConfiguration); + LDEBUG("SGCT Configuration file: " + global::configuration->windowConfiguration); - windowConfiguration = global::configuration.windowConfiguration; + windowConfiguration = global::configuration->windowConfiguration; } catch (const documentation::SpecificationError& e) { LFATALC("main", "Loading of configuration file failed"); @@ -1145,7 +1148,7 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } - global::openSpaceEngine.registerPathTokens(); + global::openSpaceEngine->registerPathTokens(); bool hasSGCTConfig = false; @@ -1164,12 +1167,12 @@ int main(int argc, char** argv) { ); bool skipLauncher = - (hasProfile && hasSGCTConfig) || global::configuration.bypassLauncher; + (hasProfile && hasSGCTConfig) || global::configuration->bypassLauncher; if (!skipLauncher) { int qac = 0; QApplication app(qac, nullptr); LauncherWindow win(!hasProfile, - global::configuration, !hasSGCTConfig, windowCfgPreset, nullptr); + *global::configuration, !hasSGCTConfig, windowCfgPreset, nullptr); win.show(); app.exec(); @@ -1177,7 +1180,7 @@ int main(int argc, char** argv) { exit(EXIT_SUCCESS); } - global::configuration.profile = win.selectedProfile(); + global::configuration->profile = win.selectedProfile(); windowConfiguration = selectedSgctProfileFromLauncher( win, hasSGCTConfig, @@ -1231,11 +1234,12 @@ int main(int argc, char** argv) { catch (const std::runtime_error& e) { LFATALC("main", e.what()); Engine::destroy(); - global::openSpaceEngine.deinitialize(); + global::openSpaceEngine->deinitialize(); ghoul::deinitialize(); + throw; } catch (...) { - global::openSpaceEngine.deinitialize(); + global::openSpaceEngine->deinitialize(); ghoul::deinitialize(); Engine::destroy(); throw; @@ -1274,8 +1278,9 @@ int main(int argc, char** argv) { Engine::instance().render(); LINFO("Ending rendering loop"); - global::openSpaceEngine.deinitializeGL(); - global::openSpaceEngine.deinitialize(); + global::openSpaceEngine->deinitializeGL(); + global::openSpaceEngine->deinitialize(); + global::destroy(); // Clear function bindings to avoid crash after destroying the OpenSpace Engine Log::instance().setLogCallback(nullptr); diff --git a/include/openspace/engine/globals.h b/include/openspace/engine/globals.h index 1fcfca9b96..2a1b946491 100644 --- a/include/openspace/engine/globals.h +++ b/include/openspace/engine/globals.h @@ -69,81 +69,42 @@ class Profile; namespace global { -namespace detail { - -ghoul::fontrendering::FontManager& gFontManager(); -Dashboard& gDashboard(); -DeferredcasterManager& gDeferredcasterManager(); -DownloadManager& gDownloadManager(); -LuaConsole& gLuaConsole(); -MemoryManager& gMemoryManager(); -MissionManager& gMissionManager(); -ModuleEngine& gModuleEngine(); -OpenSpaceEngine& gOpenSpaceEngine(); -ParallelPeer& gParallelPeer(); -RaycasterManager& gRaycasterManager(); -RenderEngine& gRenderEngine(); -std::vector>& gScreenspaceRenderables(); -SyncEngine& gSyncEngine(); -TimeManager& gTimeManager(); -VersionChecker& gVersionChecker(); -VirtualPropertyManager& gVirtualPropertyManager(); -WindowDelegate& gWindowDelegate(); -configuration::Configuration& gConfiguration(); -interaction::InteractionMonitor& gInteractionMonitor(); -interaction::JoystickInputStates& gJoystickInputStates(); -interaction::WebsocketInputStates& gWebsocketInputStates(); -interaction::KeybindingManager& gKeybindingManager(); -interaction::NavigationHandler& gNavigationHandler(); -interaction::SessionRecording& gSessionRecording(); -interaction::ShortcutManager& gShortcutManager(); -properties::PropertyOwner& gRootPropertyOwner(); -properties::PropertyOwner& gScreenSpaceRootPropertyOwner(); -scripting::ScriptEngine& gScriptEngine(); -scripting::ScriptScheduler& gScriptScheduler(); -Profile& gProfile(); - -} // namespace detail - -static ghoul::fontrendering::FontManager& fontManager = detail::gFontManager(); -static Dashboard& dashboard = detail::gDashboard(); -static DeferredcasterManager& deferredcasterManager = detail::gDeferredcasterManager(); -static DownloadManager& downloadManager = detail::gDownloadManager(); -static LuaConsole& luaConsole = detail::gLuaConsole(); -static MemoryManager& memoryManager = detail::gMemoryManager(); -static MissionManager& missionManager = detail::gMissionManager(); -static ModuleEngine& moduleEngine = detail::gModuleEngine(); -static OpenSpaceEngine& openSpaceEngine = detail::gOpenSpaceEngine(); -static ParallelPeer& parallelPeer = detail::gParallelPeer(); -static RaycasterManager& raycasterManager = detail::gRaycasterManager(); -static RenderEngine& renderEngine = detail::gRenderEngine(); -static std::vector>& screenSpaceRenderables = - detail::gScreenspaceRenderables(); -static SyncEngine& syncEngine = detail::gSyncEngine(); -static TimeManager& timeManager = detail::gTimeManager(); -static VersionChecker& versionChecker = detail::gVersionChecker(); -static VirtualPropertyManager& virtualPropertyManager = detail::gVirtualPropertyManager(); -static WindowDelegate& windowDelegate = detail::gWindowDelegate(); -static configuration::Configuration& configuration = detail::gConfiguration(); -static interaction::InteractionMonitor& interactionMonitor = - detail::gInteractionMonitor(); -static interaction::JoystickInputStates& joystickInputStates = - detail::gJoystickInputStates(); -static interaction::WebsocketInputStates& websocketInputStates = - detail::gWebsocketInputStates(); -static interaction::KeybindingManager& keybindingManager = detail::gKeybindingManager(); -static interaction::NavigationHandler& navigationHandler = detail::gNavigationHandler(); -static interaction::SessionRecording& sessionRecording = detail::gSessionRecording(); -static interaction::ShortcutManager& shortcutManager = detail::gShortcutManager(); -static properties::PropertyOwner& rootPropertyOwner = detail::gRootPropertyOwner(); -static properties::PropertyOwner& screenSpaceRootPropertyOwner = - detail::gScreenSpaceRootPropertyOwner(); -static scripting::ScriptEngine& scriptEngine = detail::gScriptEngine(); -static scripting::ScriptScheduler& scriptScheduler = detail::gScriptScheduler(); -static Profile& profile = detail::gProfile(); +inline ghoul::fontrendering::FontManager* fontManager; +inline Dashboard* dashboard; +inline DeferredcasterManager* deferredcasterManager; +inline DownloadManager* downloadManager; +inline LuaConsole* luaConsole; +inline MemoryManager* memoryManager; +inline MissionManager* missionManager; +inline ModuleEngine* moduleEngine; +inline OpenSpaceEngine* openSpaceEngine; +inline ParallelPeer* parallelPeer; +inline RaycasterManager* raycasterManager; +inline RenderEngine* renderEngine; +inline std::vector>* screenSpaceRenderables; +inline SyncEngine* syncEngine; +inline TimeManager* timeManager; +inline VersionChecker* versionChecker; +inline VirtualPropertyManager* virtualPropertyManager; +inline WindowDelegate* windowDelegate; +inline configuration::Configuration* configuration; +inline interaction::InteractionMonitor* interactionMonitor; +inline interaction::JoystickInputStates* joystickInputStates; +inline interaction::WebsocketInputStates* websocketInputStates; +inline interaction::KeybindingManager* keybindingManager; +inline interaction::NavigationHandler* navigationHandler; +inline interaction::SessionRecording* sessionRecording; +inline interaction::ShortcutManager* shortcutManager; +inline properties::PropertyOwner* rootPropertyOwner; +inline properties::PropertyOwner* screenSpaceRootPropertyOwner; +inline scripting::ScriptEngine* scriptEngine; +inline scripting::ScriptScheduler* scriptScheduler; +inline Profile* profile; +void create(); void initialize(); void initializeGL(); +void destroy(); void deinitialize(); void deinitializeGL(); diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp index 56ebd46c71..54dfbaa48e 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp @@ -335,10 +335,10 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData, const std::string source = shadowConf.source.first; SceneGraphNode* sourceNode = - global::renderEngine.scene()->sceneGraphNode(source); + global::renderEngine->scene()->sceneGraphNode(source); const std::string caster = shadowConf.caster.first; SceneGraphNode* casterNode = - global::renderEngine.scene()->sceneGraphNode(caster); + global::renderEngine->scene()->sceneGraphNode(caster); const double sourceRadiusScale = std::max( glm::compMax(sourceNode->scale()), @@ -1198,7 +1198,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO, } // Restores OpenGL blending state - global::renderEngine.openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetBlendState(); } void AtmosphereDeferredcaster::preCalculateAtmosphereParam() { @@ -1217,7 +1217,7 @@ void AtmosphereDeferredcaster::preCalculateAtmosphereParam() { glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); GLint m_viewport[4]; - global::renderEngine.openglStateCache().viewport(m_viewport); + global::renderEngine->openglStateCache().viewport(m_viewport); // Creates the FBO for the calculations GLuint calcFBO; @@ -1243,7 +1243,7 @@ void AtmosphereDeferredcaster::preCalculateAtmosphereParam() { // Restores system state glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - global::renderEngine.openglStateCache().setViewportState(m_viewport); + global::renderEngine->openglStateCache().setViewportState(m_viewport); glDeleteBuffers(1, &quadCalcVBO); glDeleteVertexArrays(1, &quadCalcVAO); glDeleteFramebuffers(1, &calcFBO); diff --git a/modules/atmosphere/rendering/renderableatmosphere.cpp b/modules/atmosphere/rendering/renderableatmosphere.cpp index 7b31587b74..62582209a1 100644 --- a/modules/atmosphere/rendering/renderableatmosphere.cpp +++ b/modules/atmosphere/rendering/renderableatmosphere.cpp @@ -651,7 +651,7 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary) void RenderableAtmosphere::deinitializeGL() { if (_deferredcaster) { - global::deferredcasterManager.detachDeferredcaster(*_deferredcaster); + global::deferredcasterManager->detachDeferredcaster(*_deferredcaster); _deferredcaster = nullptr; } } @@ -694,7 +694,7 @@ void RenderableAtmosphere::initializeGL() { _deferredcaster->initialize(); } - global::deferredcasterManager.attachDeferredcaster(*_deferredcaster); + global::deferredcasterManager->attachDeferredcaster(*_deferredcaster); } return; diff --git a/modules/base/dashboard/dashboarditemangle.cpp b/modules/base/dashboard/dashboarditemangle.cpp index e2a3c49b5d..6ad0945c11 100644 --- a/modules/base/dashboard/dashboarditemangle.cpp +++ b/modules/base/dashboard/dashboarditemangle.cpp @@ -219,12 +219,12 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary) } _fontName.onChange([this]() { - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontName); _fontSize.onChange([this]() { - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontSize); @@ -352,7 +352,7 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary) } addProperty(_destination.nodeName); - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); _buffer.resize(128); } @@ -361,7 +361,7 @@ std::pair DashboardItemAngle::positionAndLabel( { if (comp.type == Type::Node) { if (!comp.node) { - comp.node = global::renderEngine.scene()->sceneGraphNode(comp.nodeName); + comp.node = global::renderEngine->scene()->sceneGraphNode(comp.nodeName); if (!comp.node) { LERRORC( @@ -379,14 +379,14 @@ std::pair DashboardItemAngle::positionAndLabel( case Type::Focus: { const SceneGraphNode* node = - global::navigationHandler.orbitalNavigator().anchorNode(); + global::navigationHandler->orbitalNavigator().anchorNode(); return { node->worldPosition(), "focus" }; } case Type::Camera: - return { global::renderEngine.scene()->camera()->positionVec3(), "camera" }; + return { global::renderEngine->scene()->camera()->positionVec3(), "camera" }; default: return { glm::dvec3(0.0), "Unknown" }; } diff --git a/modules/base/dashboard/dashboarditemdate.cpp b/modules/base/dashboard/dashboarditemdate.cpp index 0cd58ffe29..34b0dac408 100644 --- a/modules/base/dashboard/dashboarditemdate.cpp +++ b/modules/base/dashboard/dashboarditemdate.cpp @@ -95,7 +95,7 @@ DashboardItemDate::DashboardItemDate(const ghoul::Dictionary& dictionary) _fontName = dictionary.value(FontNameInfo.identifier); } _fontName.onChange([this](){ - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontName); @@ -103,11 +103,11 @@ DashboardItemDate::DashboardItemDate(const ghoul::Dictionary& dictionary) _fontSize = static_cast(dictionary.value(FontSizeInfo.identifier)); } _fontSize.onChange([this](){ - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontSize); - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); } void DashboardItemDate::render(glm::vec2& penPosition) { @@ -116,7 +116,7 @@ void DashboardItemDate::render(glm::vec2& penPosition) { RenderFont( *_font, penPosition, - fmt::format("Date: {} UTC", global::timeManager.time().UTC()) + fmt::format("Date: {} UTC", global::timeManager->time().UTC()) ); penPosition.y -= _font->height(); } @@ -125,7 +125,7 @@ glm::vec2 DashboardItemDate::size() const { ZoneScoped return _font->boundingBox( - fmt::format("Date: {} UTC", global::timeManager.time().UTC()) + fmt::format("Date: {} UTC", global::timeManager->time().UTC()) ); } diff --git a/modules/base/dashboard/dashboarditemdistance.cpp b/modules/base/dashboard/dashboarditemdistance.cpp index 5780801960..e8f83a77bd 100644 --- a/modules/base/dashboard/dashboarditemdistance.cpp +++ b/modules/base/dashboard/dashboarditemdistance.cpp @@ -221,12 +221,12 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary } _fontName.onChange([this]() { - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontName); _fontSize.onChange([this]() { - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontSize); @@ -358,7 +358,7 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary _requestedUnit.setVisibility(properties::Property::Visibility::Hidden); addProperty(_requestedUnit); - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); _buffer.resize(256); } @@ -369,7 +369,7 @@ std::pair DashboardItemDistance::positionAndLabel( { if ((mainComp.type == Type::Node) || (mainComp.type == Type::NodeSurface)) { if (!mainComp.node) { - mainComp.node = global::renderEngine.scene()->sceneGraphNode( + mainComp.node = global::renderEngine->scene()->sceneGraphNode( mainComp.nodeName ); @@ -406,7 +406,7 @@ std::pair DashboardItemDistance::positionAndLabel( } case Type::Focus: { const SceneGraphNode* anchor = - global::navigationHandler.orbitalNavigator().anchorNode(); + global::navigationHandler->orbitalNavigator().anchorNode(); if (!anchor) { return { glm::dvec3(0.0), "Unknown" }; } @@ -415,7 +415,7 @@ std::pair DashboardItemDistance::positionAndLabel( } } case Type::Camera: - return { global::renderEngine.scene()->camera()->positionVec3(), "camera" }; + return { global::renderEngine->scene()->camera()->positionVec3(), "camera" }; default: return { glm::dvec3(0.0), "Unknown" }; } diff --git a/modules/base/dashboard/dashboarditemframerate.cpp b/modules/base/dashboard/dashboarditemframerate.cpp index 8471fa2280..27e583f6d8 100644 --- a/modules/base/dashboard/dashboarditemframerate.cpp +++ b/modules/base/dashboard/dashboarditemframerate.cpp @@ -75,7 +75,7 @@ namespace { return fmt::format_to( buffer.data(), "Avg. Frametime: {:.2f} ms\0", - openspace::global::windowDelegate.averageDeltaTime() * 1000.0 + openspace::global::windowDelegate->averageDeltaTime() * 1000.0 ); } @@ -87,8 +87,8 @@ namespace { buffer.data(), "Last frametimes between: {:.2f} and {:.2f} ms\n" "Overall between: {:.2f} and {:.2f} ms\0", - openspace::global::windowDelegate.minDeltaTime() * 1000.0, - openspace::global::windowDelegate.maxDeltaTime() * 1000.0, + openspace::global::windowDelegate->minDeltaTime() * 1000.0, + openspace::global::windowDelegate->maxDeltaTime() * 1000.0, minFrametimeCache, maxFrametimeCache ); @@ -98,7 +98,7 @@ namespace { return fmt::format_to( buffer.data(), "Frametime standard deviation : {:.2f} ms\0", - openspace::global::windowDelegate.deltaTimeStandardDeviation() * 1000.0 + openspace::global::windowDelegate->deltaTimeStandardDeviation() * 1000.0 ); } @@ -106,8 +106,8 @@ namespace { return fmt::format_to( buffer.data(), "Frametime coefficient of variation : {:.2f} %\0", - openspace::global::windowDelegate.deltaTimeStandardDeviation() / - openspace::global::windowDelegate.averageDeltaTime() * 100.0 + openspace::global::windowDelegate->deltaTimeStandardDeviation() / + openspace::global::windowDelegate->averageDeltaTime() * 100.0 ); } @@ -115,7 +115,7 @@ namespace { return fmt::format_to( buffer.data(), "FPS: {:3.2f}\0", - 1.0 / openspace::global::windowDelegate.deltaTime() + 1.0 / openspace::global::windowDelegate->deltaTime() ); } @@ -123,7 +123,7 @@ namespace { return fmt::format_to( buffer.data(), "Avg. FPS: {:3.2f}\0", - 1.0 / openspace::global::windowDelegate.averageDeltaTime() + 1.0 / openspace::global::windowDelegate->averageDeltaTime() ); } @@ -221,7 +221,7 @@ DashboardItemFramerate::DashboardItemFramerate(const ghoul::Dictionary& dictiona _fontName = dictionary.value(FontNameInfo.identifier); } _fontName.onChange([this]() { - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontName); @@ -231,7 +231,7 @@ DashboardItemFramerate::DashboardItemFramerate(const ghoul::Dictionary& dictiona ); } _fontSize.onChange([this](){ - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontSize); @@ -287,7 +287,7 @@ DashboardItemFramerate::DashboardItemFramerate(const ghoul::Dictionary& dictiona }); addProperty(_clearCache); - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); _buffer.resize(128); } @@ -303,11 +303,11 @@ void DashboardItemFramerate::render(glm::vec2& penPosition) { _minDeltaTimeCache = std::min( _minDeltaTimeCache, - global::windowDelegate.minDeltaTime() * 1000.0 + global::windowDelegate->minDeltaTime() * 1000.0 ); _maxDeltaTimeCache = std::max( _maxDeltaTimeCache, - global::windowDelegate.maxDeltaTime() * 1000.0 + global::windowDelegate->maxDeltaTime() * 1000.0 ); FrametimeType frametimeType = FrametimeType(_frametimeType.value()); diff --git a/modules/base/dashboard/dashboarditemmission.cpp b/modules/base/dashboard/dashboarditemmission.cpp index e2be50766f..881a12b953 100644 --- a/modules/base/dashboard/dashboarditemmission.cpp +++ b/modules/base/dashboard/dashboarditemmission.cpp @@ -114,7 +114,7 @@ DashboardItemMission::DashboardItemMission(const ghoul::Dictionary& dictionary) _fontName = dictionary.value(FontNameInfo.identifier); } _fontName.onChange([this](){ - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontName); @@ -122,21 +122,21 @@ DashboardItemMission::DashboardItemMission(const ghoul::Dictionary& dictionary) _fontSize = static_cast(dictionary.value(FontSizeInfo.identifier)); } _fontSize.onChange([this](){ - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontSize); - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); } void DashboardItemMission::render(glm::vec2& penPosition) { ZoneScoped - if (!global::missionManager.hasCurrentMission()) { + if (!global::missionManager->hasCurrentMission()) { return; } - double currentTime = global::timeManager.time().j2000Seconds(); - const Mission& mission = global::missionManager.currentMission(); + double currentTime = global::timeManager->time().j2000Seconds(); + const Mission& mission = global::missionManager->currentMission(); if (mission.phases().empty()) { return; diff --git a/modules/base/dashboard/dashboarditemparallelconnection.cpp b/modules/base/dashboard/dashboarditemparallelconnection.cpp index be39c9bac4..8f23e4928d 100644 --- a/modules/base/dashboard/dashboarditemparallelconnection.cpp +++ b/modules/base/dashboard/dashboarditemparallelconnection.cpp @@ -99,7 +99,7 @@ DashboardItemParallelConnection::DashboardItemParallelConnection( _fontName = dictionary.value(FontNameInfo.identifier); } _fontName.onChange([this](){ - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontName); @@ -107,19 +107,19 @@ DashboardItemParallelConnection::DashboardItemParallelConnection( _fontSize = static_cast(dictionary.value(FontSizeInfo.identifier)); } _fontSize.onChange([this](){ - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontSize); - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); } void DashboardItemParallelConnection::render(glm::vec2& penPosition) { ZoneScoped - const ParallelConnection::Status status = global::parallelPeer.status(); - const size_t nConnections = global::parallelPeer.nConnections(); - const std::string& hostName = global::parallelPeer.hostName(); + const ParallelConnection::Status status = global::parallelPeer->status(); + const size_t nConnections = global::parallelPeer->nConnections(); + const std::string& hostName = global::parallelPeer->hostName(); int nLines = 1; @@ -173,9 +173,9 @@ void DashboardItemParallelConnection::render(glm::vec2& penPosition) { glm::vec2 DashboardItemParallelConnection::size() const { ZoneScoped - ParallelConnection::Status status = global::parallelPeer.status(); - size_t nConnections = global::parallelPeer.nConnections(); - const std::string& hostName = global::parallelPeer.hostName(); + ParallelConnection::Status status = global::parallelPeer->status(); + size_t nConnections = global::parallelPeer->nConnections(); + const std::string& hostName = global::parallelPeer->hostName(); std::string connectionInfo; int nClients = static_cast(nConnections); diff --git a/modules/base/dashboard/dashboarditempropertyvalue.cpp b/modules/base/dashboard/dashboarditempropertyvalue.cpp index 052370463d..7040b00a07 100644 --- a/modules/base/dashboard/dashboarditempropertyvalue.cpp +++ b/modules/base/dashboard/dashboarditempropertyvalue.cpp @@ -125,7 +125,7 @@ DashboardItemPropertyValue::DashboardItemPropertyValue( _fontName = dictionary.value(FontNameInfo.identifier); } _fontName.onChange([this](){ - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontName); @@ -133,7 +133,7 @@ DashboardItemPropertyValue::DashboardItemPropertyValue( _fontSize = static_cast(dictionary.value(FontSizeInfo.identifier)); } _fontSize.onChange([this](){ - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontSize); @@ -148,7 +148,7 @@ DashboardItemPropertyValue::DashboardItemPropertyValue( } addProperty(_displayString); - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); } void DashboardItemPropertyValue::render(glm::vec2& penPosition) { diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.cpp b/modules/base/dashboard/dashboarditemsimulationincrement.cpp index 06b6375cf0..503f178d98 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.cpp +++ b/modules/base/dashboard/dashboarditemsimulationincrement.cpp @@ -137,7 +137,7 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement( _fontName = dictionary.value(FontNameInfo.identifier); } _fontName.onChange([this](){ - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontName); @@ -145,7 +145,7 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement( _fontSize = static_cast(dictionary.value(FontSizeInfo.identifier)); } _fontSize.onChange([this](){ - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontSize); @@ -173,14 +173,14 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement( _requestedUnit.setVisibility(properties::Property::Visibility::Hidden); addProperty(_requestedUnit); - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); } void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { ZoneScoped - const double targetDt = global::timeManager.targetDeltaTime(); - const double currentDt = global::timeManager.deltaTime(); + const double targetDt = global::timeManager->targetDeltaTime(); + const double currentDt = global::timeManager->deltaTime(); std::pair targetDeltaTime; std::pair currentDeltaTime; if (_doSimplification) { @@ -201,9 +201,9 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { } } - std::string pauseText = global::timeManager.isPaused() ? " (Paused)" : ""; + std::string pauseText = global::timeManager->isPaused() ? " (Paused)" : ""; - if (targetDt != currentDt && !global::timeManager.isPaused()) { + if (targetDt != currentDt && !global::timeManager->isPaused()) { // We are in the middle of a transition RenderFont( *_font, @@ -232,7 +232,7 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { glm::vec2 DashboardItemSimulationIncrement::size() const { ZoneScoped - double t = global::timeManager.targetDeltaTime(); + double t = global::timeManager->targetDeltaTime(); std::pair deltaTime; if (_doSimplification) { deltaTime = simplifyTime(t); diff --git a/modules/base/dashboard/dashboarditemvelocity.cpp b/modules/base/dashboard/dashboarditemvelocity.cpp index 7c12cc40be..5431ba92a0 100644 --- a/modules/base/dashboard/dashboarditemvelocity.cpp +++ b/modules/base/dashboard/dashboarditemvelocity.cpp @@ -149,12 +149,12 @@ DashboardItemVelocity::DashboardItemVelocity(const ghoul::Dictionary& dictionary } _fontName.onChange([this]() { - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontName); _fontSize.onChange([this]() { - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontSize); @@ -184,17 +184,17 @@ DashboardItemVelocity::DashboardItemVelocity(const ghoul::Dictionary& dictionary _requestedUnit.setVisibility(properties::Property::Visibility::Hidden); addProperty(_requestedUnit); - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); } void DashboardItemVelocity::render(glm::vec2& penPosition) { ZoneScoped - const glm::dvec3 currentPos = global::renderEngine.scene()->camera()->positionVec3(); + const glm::dvec3 currentPos = global::renderEngine->scene()->camera()->positionVec3(); const glm::dvec3 dt = currentPos - _prevPosition; const double speedPerFrame = glm::length(dt); - const double secondsPerFrame = global::windowDelegate.averageDeltaTime(); + const double secondsPerFrame = global::windowDelegate->averageDeltaTime(); const double speedPerSecond = speedPerFrame / secondsPerFrame; diff --git a/modules/base/lightsource/scenegraphlightsource.cpp b/modules/base/lightsource/scenegraphlightsource.cpp index 4d2432fad9..50f6695d5b 100644 --- a/modules/base/lightsource/scenegraphlightsource.cpp +++ b/modules/base/lightsource/scenegraphlightsource.cpp @@ -110,7 +110,7 @@ SceneGraphLightSource::SceneGraphLightSource(const ghoul::Dictionary& dictionary _sceneGraphNodeReference.onChange([this]() { _sceneGraphNode = - global::renderEngine.scene()->sceneGraphNode(_sceneGraphNodeReference); + global::renderEngine->scene()->sceneGraphNode(_sceneGraphNodeReference); }); } @@ -119,7 +119,7 @@ bool SceneGraphLightSource::initialize() { ZoneScoped _sceneGraphNode = - global::renderEngine.scene()->sceneGraphNode(_sceneGraphNodeReference); + global::renderEngine->scene()->sceneGraphNode(_sceneGraphNodeReference); return _sceneGraphNode != nullptr; } diff --git a/modules/base/rendering/grids/renderableboxgrid.cpp b/modules/base/rendering/grids/renderableboxgrid.cpp index 672ebc2e6d..c05f583011 100644 --- a/modules/base/rendering/grids/renderableboxgrid.cpp +++ b/modules/base/rendering/grids/renderableboxgrid.cpp @@ -137,7 +137,7 @@ void RenderableBoxGrid::initializeGL() { _gridProgram = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_BASE}/shaders/grid_vs.glsl"), absPath("${MODULE_BASE}/shaders/grid_fs.glsl") @@ -164,7 +164,7 @@ void RenderableBoxGrid::deinitializeGL() { BaseModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _gridProgram = nullptr; @@ -203,8 +203,8 @@ void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){ _gridProgram->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().resetBlendState(); - global::renderEngine.openglStateCache().resetLineState(); + global::renderEngine->openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetLineState(); } void RenderableBoxGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index 1bd1617c42..e8b8857103 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -153,7 +153,7 @@ void RenderableGrid::initializeGL() { _gridProgram = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_BASE}/shaders/grid_vs.glsl"), absPath("${MODULE_BASE}/shaders/grid_fs.glsl") @@ -180,7 +180,7 @@ void RenderableGrid::deinitializeGL() { BaseModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _gridProgram = nullptr; @@ -219,8 +219,8 @@ void RenderableGrid::render(const RenderData& data, RendererTasks&){ _gridProgram->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().resetBlendState(); - global::renderEngine.openglStateCache().resetLineState(); + global::renderEngine->openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetLineState(); } void RenderableGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/grids/renderableradialgrid.cpp b/modules/base/rendering/grids/renderableradialgrid.cpp index 7e94730f67..0b61d9fc56 100644 --- a/modules/base/rendering/grids/renderableradialgrid.cpp +++ b/modules/base/rendering/grids/renderableradialgrid.cpp @@ -221,7 +221,7 @@ void RenderableRadialGrid::initializeGL() { _gridProgram = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_BASE}/shaders/grid_vs.glsl"), absPath("${MODULE_BASE}/shaders/grid_fs.glsl") @@ -234,7 +234,7 @@ void RenderableRadialGrid::deinitializeGL() { BaseModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _gridProgram = nullptr; @@ -282,8 +282,8 @@ void RenderableRadialGrid::render(const RenderData& data, RendererTasks&) { _gridProgram->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().resetBlendState(); - global::renderEngine.openglStateCache().resetLineState(); + global::renderEngine->openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetLineState(); } void RenderableRadialGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/grids/renderablesphericalgrid.cpp b/modules/base/rendering/grids/renderablesphericalgrid.cpp index 8c537ced91..76e2467944 100644 --- a/modules/base/rendering/grids/renderablesphericalgrid.cpp +++ b/modules/base/rendering/grids/renderablesphericalgrid.cpp @@ -145,7 +145,7 @@ void RenderableSphericalGrid::initializeGL() { _gridProgram = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_BASE}/shaders/grid_vs.glsl"), absPath("${MODULE_BASE}/shaders/grid_fs.glsl") @@ -177,7 +177,7 @@ void RenderableSphericalGrid::deinitializeGL() { BaseModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _gridProgram = nullptr; @@ -224,8 +224,8 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){ _gridProgram->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().resetBlendState(); - global::renderEngine.openglStateCache().resetLineState(); + global::renderEngine->openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetLineState(); } void RenderableSphericalGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index b51938be98..f6a2e8424f 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -96,7 +96,7 @@ ghoul::mm_unique_ptr ModelGeometry::createFromDictionary( ModelGeometry* geometry = factory->create( geometryType, dictionary, - &global::memoryManager.PersistentMemory + &global::memoryManager->PersistentMemory ); return ghoul::mm_unique_ptr(geometry); } diff --git a/modules/base/rendering/renderablecartesianaxes.cpp b/modules/base/rendering/renderablecartesianaxes.cpp index 152fbea5a8..e188f362ac 100644 --- a/modules/base/rendering/renderablecartesianaxes.cpp +++ b/modules/base/rendering/renderablecartesianaxes.cpp @@ -146,7 +146,7 @@ void RenderableCartesianAxes::initializeGL() { _program = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_BASE}/shaders/axes_vs.glsl"), absPath("${MODULE_BASE}/shaders/axes_fs.glsl") @@ -210,7 +210,7 @@ void RenderableCartesianAxes::deinitializeGL() { BaseModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _program = nullptr; @@ -247,8 +247,8 @@ void RenderableCartesianAxes::render(const RenderData& data, RendererTasks&){ _program->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().resetBlendState(); - global::renderEngine.openglStateCache().resetLineState(); + global::renderEngine->openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetLineState(); } } // namespace openspace diff --git a/modules/base/rendering/renderablelabels.cpp b/modules/base/rendering/renderablelabels.cpp index c435137a97..efadca6ec9 100644 --- a/modules/base/rendering/renderablelabels.cpp +++ b/modules/base/rendering/renderablelabels.cpp @@ -399,7 +399,7 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary) _fontSize = dictionary.value(FontSizeInfo.identifier); } _fontSize.onChange([&]() { - _font = global::fontManager.font( + _font = global::fontManager->font( "Mono", _fontSize, ghoul::fontrendering::FontManager::Outline::Yes, @@ -612,7 +612,7 @@ void RenderableLabels::initialize() { void RenderableLabels::initializeGL() { if (_font == nullptr) { //size_t _fontSize = 50; - _font = global::fontManager.font( + _font = global::fontManager->font( "Mono", _fontSize, ghoul::fontrendering::FontManager::Outline::Yes, diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index e975a74247..0aa9bb2273 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -291,7 +291,7 @@ void RenderableModel::initializeGL() { _program = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_BASE}/shaders/model_vs.glsl"), absPath("${MODULE_BASE}/shaders/model_fs.glsl") @@ -315,7 +315,7 @@ void RenderableModel::deinitializeGL() { BaseModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _program = nullptr; diff --git a/modules/base/rendering/renderablenodeline.cpp b/modules/base/rendering/renderablenodeline.cpp index 34f579126c..fe875fd7df 100644 --- a/modules/base/rendering/renderablenodeline.cpp +++ b/modules/base/rendering/renderablenodeline.cpp @@ -76,7 +76,7 @@ namespace { glm::dvec3 anchorNodePos(0.0); const interaction::OrbitalNavigator& nav = - global::navigationHandler.orbitalNavigator(); + global::navigationHandler->orbitalNavigator(); if (nav.anchorNode()) { anchorNodePos = nav.anchorNode()->worldPosition(); @@ -178,7 +178,7 @@ void RenderableNodeLine::initializeGL() { _program = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_BASE}/shaders/line_vs.glsl"), absPath("${MODULE_BASE}/shaders/line_fs.glsl") @@ -208,8 +208,8 @@ void RenderableNodeLine::deinitializeGL() { BaseModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); - } + global::renderEngine->removeRenderProgram(p); + } ); _program = nullptr; } @@ -235,10 +235,10 @@ void RenderableNodeLine::updateVertexData() { // Update the positions of the nodes _startPos = coordinatePosFromAnchorNode( - global::renderEngine.scene()->sceneGraphNode(_start)->worldPosition() + global::renderEngine->scene()->sceneGraphNode(_start)->worldPosition() ); _endPos = coordinatePosFromAnchorNode( - global::renderEngine.scene()->sceneGraphNode(_end)->worldPosition() + global::renderEngine->scene()->sceneGraphNode(_end)->worldPosition() ); _vertexArray.push_back(static_cast(_startPos.x)); @@ -272,10 +272,10 @@ void RenderableNodeLine::render(const RenderData& data, RendererTasks&) { glm::dmat4 anchorTranslation(1.0); // Update anchor node information, used to counter precision problems - if (global::navigationHandler.orbitalNavigator().anchorNode()) { + if (global::navigationHandler->orbitalNavigator().anchorNode()) { anchorTranslation = glm::translate( glm::dmat4(1.0), - global::navigationHandler.orbitalNavigator().anchorNode()->worldPosition() + global::navigationHandler->orbitalNavigator().anchorNode()->worldPosition() ); } @@ -304,18 +304,18 @@ void RenderableNodeLine::render(const RenderData& data, RendererTasks&) { // Restore GL State unbindGL(); _program->deactivate(); - global::renderEngine.openglStateCache().resetBlendState(); - global::renderEngine.openglStateCache().resetLineState(); + global::renderEngine->openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetLineState(); } void RenderableNodeLine::validateNodes() { - if (!global::renderEngine.scene()->sceneGraphNode(_start)) { + if (!global::renderEngine->scene()->sceneGraphNode(_start)) { LERROR(fmt::format( "There is no scenegraph node with id {}, defaults to 'Root'", _start )); _start = Root; } - if (!global::renderEngine.scene()->sceneGraphNode(_end)) { + if (!global::renderEngine->scene()->sceneGraphNode(_end)) { LERROR(fmt::format( "There is no scenegraph node with id {}, defaults to 'Root'", _end )); diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 3437bbd97f..93202d9578 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -176,7 +176,7 @@ void RenderablePlane::initializeGL() { _shader = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_BASE}/shaders/plane_vs.glsl"), absPath("${MODULE_BASE}/shaders/plane_fs.glsl") @@ -197,7 +197,7 @@ void RenderablePlane::deinitializeGL() { BaseModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _shader = nullptr; @@ -251,10 +251,10 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) { _shader->setUniform("texture1", unit); - bool usingFramebufferRenderer = global::renderEngine.rendererImplementation() == + bool usingFramebufferRenderer = global::renderEngine->rendererImplementation() == RenderEngine::RendererImplementation::Framebuffer; - bool usingABufferRenderer = global::renderEngine.rendererImplementation() == + bool usingABufferRenderer = global::renderEngine->rendererImplementation() == RenderEngine::RendererImplementation::ABuffer; if (usingABufferRenderer) { diff --git a/modules/base/rendering/renderableplaneimageonline.cpp b/modules/base/rendering/renderableplaneimageonline.cpp index 3914cd2ae0..86b93d5bd2 100644 --- a/modules/base/rendering/renderableplaneimageonline.cpp +++ b/modules/base/rendering/renderableplaneimageonline.cpp @@ -152,7 +152,7 @@ void RenderablePlaneImageOnline::update(const UpdateData&) { std::future RenderablePlaneImageOnline::downloadImageToMemory(const std::string& url) { - return global::downloadManager.fetchFile( + return global::downloadManager->fetchFile( url, [url](const DownloadManager::MemoryFile&) { LDEBUGC( diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index ae9a58ae92..f097a5a806 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -310,7 +310,7 @@ void RenderableSphere::initializeGL() { _shader = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_BASE}/shaders/sphere_vs.glsl"), absPath("${MODULE_BASE}/shaders/sphere_fs.glsl") @@ -329,7 +329,7 @@ void RenderableSphere::deinitializeGL() { BaseModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _shader = nullptr; @@ -430,10 +430,10 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { glDisable(GL_CULL_FACE); } - bool usingFramebufferRenderer = global::renderEngine.rendererImplementation() == + bool usingFramebufferRenderer = global::renderEngine->rendererImplementation() == RenderEngine::RendererImplementation::Framebuffer; - bool usingABufferRenderer = global::renderEngine.rendererImplementation() == + bool usingABufferRenderer = global::renderEngine->rendererImplementation() == RenderEngine::RendererImplementation::ABuffer; if (usingABufferRenderer && _useAdditiveBlending) { diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index 102cf6f5ee..9c96849da0 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -288,7 +288,7 @@ void RenderableTrail::initializeGL() { _programObject = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_BASE}/shaders/renderabletrail_apple_vs.glsl"), absPath("${MODULE_BASE}/shaders/renderabletrail_apple_fs.glsl") @@ -299,7 +299,7 @@ void RenderableTrail::initializeGL() { _programObject = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_BASE}/shaders/renderabletrail_vs.glsl"), absPath("${MODULE_BASE}/shaders/renderabletrail_fs.glsl") @@ -315,7 +315,7 @@ void RenderableTrail::deinitializeGL() { BaseModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _programObject = nullptr; @@ -359,7 +359,7 @@ void RenderableTrail::internalRender(bool renderLines, bool renderPoints, _programObject->setUniform(_uniformCache.nVertices, nVertices); #if !defined(__APPLE__) - glm::ivec2 resolution = global::renderEngine.renderingResolution(); + glm::ivec2 resolution = global::renderEngine->renderingResolution(); _programObject->setUniform(_uniformCache.resolution, resolution); _programObject->setUniform( _uniformCache.lineWidth, @@ -444,7 +444,7 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { _programObject->setUniform(_uniformCache.resolution, resolution);*/ const bool usingFramebufferRenderer = - global::renderEngine.rendererImplementation() == + global::renderEngine->rendererImplementation() == RenderEngine::RendererImplementation::Framebuffer; if (usingFramebufferRenderer) { diff --git a/modules/base/rendering/screenspacedashboard.cpp b/modules/base/rendering/screenspacedashboard.cpp index a6dfd3a214..2ddcb82b82 100644 --- a/modules/base/rendering/screenspacedashboard.cpp +++ b/modules/base/rendering/screenspacedashboard.cpp @@ -70,7 +70,7 @@ int addDashboardItemToScreenSpace(lua_State* L) { return 0; } - ScreenSpaceRenderable* ssr = global::renderEngine.screenSpaceRenderable(name); + ScreenSpaceRenderable* ssr = global::renderEngine->screenSpaceRenderable(name); if (!ssr) { return ghoul::lua::luaError(L, "Provided name is not a ScreenSpace item"); @@ -98,7 +98,7 @@ int removeDashboardItemsFromScreenSpace(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::removeDashboardItemsFromScreenSpace"); const std::string& name = ghoul::lua::value(L, 1); - ScreenSpaceRenderable* ssr = global::renderEngine.screenSpaceRenderable(name); + ScreenSpaceRenderable* ssr = global::renderEngine->screenSpaceRenderable(name); if (!ssr) { return ghoul::lua::luaError(L, "Provided name is not a ScreenSpace item"); @@ -177,7 +177,7 @@ bool ScreenSpaceDashboard::initializeGL() { glm::vec2 penPosition = glm::vec2(10.f, _size.value().w ); if (_useMainDashboard) { - global::dashboard.render(penPosition); + global::dashboard->render(penPosition); } else { _dashboard.render(penPosition); @@ -200,8 +200,8 @@ bool ScreenSpaceDashboard::isReady() const { } void ScreenSpaceDashboard::update() { - if (global::windowDelegate.windowHasResized()) { - const glm::ivec2 size = global::windowDelegate.currentDrawBufferResolution(); + if (global::windowDelegate->windowHasResized()) { + const glm::ivec2 size = global::windowDelegate->currentDrawBufferResolution(); _size = { 0.f, 0.f, size.x, size.y }; createFramebuffer(); } diff --git a/modules/base/rendering/screenspaceframebuffer.cpp b/modules/base/rendering/screenspaceframebuffer.cpp index 2efde757e7..e2d0e6a409 100644 --- a/modules/base/rendering/screenspaceframebuffer.cpp +++ b/modules/base/rendering/screenspaceframebuffer.cpp @@ -78,7 +78,7 @@ ScreenSpaceFramebuffer::ScreenSpaceFramebuffer(const ghoul::Dictionary& dictiona setGuiName("ScreenSpaceFramebuffer " + std::to_string(iIdentifier)); } - glm::vec2 resolution = global::windowDelegate.currentDrawBufferResolution(); + glm::vec2 resolution = global::windowDelegate->currentDrawBufferResolution(); addProperty(_size); _size.set(glm::vec4(0, 0, resolution.x,resolution.y)); } @@ -104,7 +104,7 @@ bool ScreenSpaceFramebuffer::deinitializeGL() { } void ScreenSpaceFramebuffer::render() { - const glm::vec2& resolution = global::windowDelegate.currentDrawBufferResolution(); + const glm::vec2& resolution = global::windowDelegate->currentDrawBufferResolution(); const glm::vec4& size = _size.value(); const float xratio = resolution.x / (size.z - size.x); @@ -113,14 +113,14 @@ void ScreenSpaceFramebuffer::render() { if (!_renderFunctions.empty()) { GLint viewport[4]; //glGetIntegerv(GL_VIEWPORT, viewport); - global::renderEngine.openglStateCache().viewport(viewport); + global::renderEngine->openglStateCache().viewport(viewport); glViewport( static_cast(-size.x * xratio), static_cast(-size.y * yratio), static_cast(resolution.x * xratio), static_cast(resolution.y * yratio) ); - global::renderEngine.openglStateCache().setViewportState(viewport); + global::renderEngine->openglStateCache().setViewportState(viewport); GLint defaultFBO = _framebuffer->getActiveObject(); _framebuffer->activate(); @@ -171,7 +171,7 @@ void ScreenSpaceFramebuffer::removeAllRenderFunctions() { } void ScreenSpaceFramebuffer::createFramebuffer() { - glm::vec2 resolution = global::windowDelegate.currentDrawBufferResolution(); + glm::vec2 resolution = global::windowDelegate->currentDrawBufferResolution(); _framebuffer = std::make_unique(); _framebuffer->activate(); diff --git a/modules/base/rendering/screenspaceimageonline.cpp b/modules/base/rendering/screenspaceimageonline.cpp index 5dd4b7c736..8597122c44 100644 --- a/modules/base/rendering/screenspaceimageonline.cpp +++ b/modules/base/rendering/screenspaceimageonline.cpp @@ -162,7 +162,7 @@ void ScreenSpaceImageOnline::update() { std::future ScreenSpaceImageOnline::downloadImageToMemory( const std::string& url) { - return global::downloadManager.fetchFile( + return global::downloadManager->fetchFile( url, [url](const DownloadManager::MemoryFile&) { LDEBUGC( diff --git a/modules/cefwebgui/cefwebguimodule.cpp b/modules/cefwebgui/cefwebguimodule.cpp index 7de3a160de..ceecc0e650 100644 --- a/modules/cefwebgui/cefwebguimodule.cpp +++ b/modules/cefwebgui/cefwebguimodule.cpp @@ -89,9 +89,9 @@ CefWebGuiModule::CefWebGuiModule() void CefWebGuiModule::startOrStopGui() { ZoneScoped - WebBrowserModule* webBrowserModule = global::moduleEngine.module(); + WebBrowserModule* webBrowserModule = global::moduleEngine->module(); - const bool isMaster = global::windowDelegate.isMaster(); + const bool isMaster = global::windowDelegate->isMaster(); if (_enabled && isMaster) { LDEBUGC("WebBrowser", fmt::format("Loading GUI from {}", _url)); @@ -103,9 +103,9 @@ void CefWebGuiModule::startOrStopGui() { ); _instance->initialize(); _instance->reshape(static_cast( - static_cast(global::windowDelegate.currentSubwindowSize()) * - global::windowDelegate.dpiScaling() - )); + static_cast(global::windowDelegate->currentSubwindowSize()) * + global::windowDelegate->dpiScaling() + )); if (!_url.value().empty()) { _instance->loadUrl(_url); } @@ -130,7 +130,7 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) ZoneScoped WebBrowserModule* webBrowserModule = - global::moduleEngine.module(); + global::moduleEngine->module(); bool available = webBrowserModule && webBrowserModule->isEnabled(); @@ -185,7 +185,7 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) // TODO: See if the hardcoded endpoint `frontend` below can be removed. // Possible fix: Reload browser if cefwebgui is routed to localhost // and the same endpoint that just came online. - WebGuiModule* webGuiModule = global::moduleEngine.module(); + WebGuiModule* webGuiModule = global::moduleEngine->module(); _endpointCallback = webGuiModule->addEndpointChangeCallback( [this](const std::string& endpoint, bool exists) { @@ -214,16 +214,16 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) ZoneScopedN("CefWebGuiModule") const bool isGuiWindow = - global::windowDelegate.hasGuiWindow() ? - global::windowDelegate.isGuiWindow() : + global::windowDelegate->hasGuiWindow() ? + global::windowDelegate->isGuiWindow() : true; - const bool isMaster = global::windowDelegate.isMaster(); + const bool isMaster = global::windowDelegate->isMaster(); if (isGuiWindow && isMaster && _instance) { - if (global::windowDelegate.windowHasResized() || _instance->_shouldReshape) { - glm::ivec2 csws = global::windowDelegate.currentSubwindowSize(); + if (global::windowDelegate->windowHasResized() || _instance->_shouldReshape) { + glm::ivec2 csws = global::windowDelegate->currentSubwindowSize(); _instance->reshape(static_cast( - static_cast(csws) * global::windowDelegate.dpiScaling() + static_cast(csws) * global::windowDelegate->dpiScaling() )); _instance->_shouldReshape = false; } @@ -237,7 +237,7 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) ZoneScopedN("CefWebGuiModule") if (_endpointCallback != -1) { - WebGuiModule* webGuiModule = global::moduleEngine.module(); + WebGuiModule* webGuiModule = global::moduleEngine->module(); webGuiModule->removeEndpointChangeCallback(_endpointCallback); _endpointCallback = -1; } diff --git a/modules/debugging/rendering/debugrenderer.cpp b/modules/debugging/rendering/debugrenderer.cpp index 362bfe6580..56058fe9eb 100644 --- a/modules/debugging/rendering/debugrenderer.cpp +++ b/modules/debugging/rendering/debugrenderer.cpp @@ -42,7 +42,7 @@ namespace openspace { DebugRenderer* DebugRenderer::_reference = nullptr; DebugRenderer::DebugRenderer() { - _programObject = global::renderEngine.buildRenderProgram( + _programObject = global::renderEngine->buildRenderProgram( "BasicDebugShader", absPath("${MODULE_DEBUGGING}/rendering/debugshader_vs.glsl"), absPath("${MODULE_DEBUGGING}/rendering/debugshader_fs.glsl") diff --git a/modules/debugging/rendering/renderabledebugplane.cpp b/modules/debugging/rendering/renderabledebugplane.cpp index 770211d15a..a54ab4504d 100644 --- a/modules/debugging/rendering/renderabledebugplane.cpp +++ b/modules/debugging/rendering/renderabledebugplane.cpp @@ -187,7 +187,7 @@ void RenderableDebugPlane::initializeGL() { createPlane(); if (!_shader) { - _shader = global::renderEngine.buildRenderProgram("PlaneProgram", + _shader = global::renderEngine->buildRenderProgram("PlaneProgram", absPath("${MODULE_BASE}/shaders/plane_vs.glsl"), absPath("${MODULE_BASE}/shaders/plane_fs.glsl") ); @@ -202,7 +202,7 @@ void RenderableDebugPlane::deinitializeGL() { _vertexPositionBuffer = 0; if (_shader) { - global::renderEngine.removeRenderProgram(_shader.get()); + global::renderEngine->removeRenderProgram(_shader.get()); _shader = nullptr; } } diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index 7481deea0c..ef9aaf92bd 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -785,7 +785,7 @@ void RenderableBillboardsCloud::initializeGL() { _program = DigitalUniverseModule::ProgramObjectManager.request( ProgramObjectName, []() { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramObjectName, absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_vs.glsl"), absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_fs.glsl"), @@ -815,7 +815,7 @@ void RenderableBillboardsCloud::initializeGL() { if (_hasLabel) { if (_font == nullptr) { size_t _fontSize = 50; - _font = global::fontManager.font( + _font = global::fontManager->font( "Mono", static_cast(_fontSize), ghoul::fontrendering::FontManager::Outline::Yes, @@ -834,7 +834,7 @@ void RenderableBillboardsCloud::deinitializeGL() { DigitalUniverseModule::ProgramObjectManager.release( ProgramObjectName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _program = nullptr; @@ -866,7 +866,7 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, _program->setUniform( "screenSize", - glm::vec2(global::renderEngine.renderingResolution()) + glm::vec2(global::renderEngine->renderingResolution()) ); _program->setUniform(_uniformCache.cameraPos, data.camera.positionVec3()); @@ -925,8 +925,8 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, glBindVertexArray(0); _program->deactivate(); - global::renderEngine.openglStateCache().resetBlendState(); - global::renderEngine.openglStateCache().resetDepthState(); + global::renderEngine->openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetDepthState(); } void RenderableBillboardsCloud::renderLabels(const RenderData& data, diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index 38f12c8326..afff95f42d 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -249,7 +249,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) _renderOption.addOption(RenderOptionViewDirection, "Camera View Direction"); _renderOption.addOption(RenderOptionPositionNormal, "Camera Position Normal"); - if (global::windowDelegate.isFisheyeRendering()) { + if (global::windowDelegate->isFisheyeRendering()) { _renderOption = RenderOptionPositionNormal; } else { @@ -352,7 +352,7 @@ void RenderableDUMeshes::initializeGL() { _program = DigitalUniverseModule::ProgramObjectManager.request( ProgramObjectName, []() { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( "RenderableDUMeshes", absPath("${MODULE_DIGITALUNIVERSE}/shaders/dumesh_vs.glsl"), absPath("${MODULE_DIGITALUNIVERSE}/shaders/dumesh_fs.glsl") @@ -372,7 +372,7 @@ void RenderableDUMeshes::initializeGL() { if (_hasLabel) { if (!_font) { constexpr const int FontSize = 50; - _font = global::fontManager.font( + _font = global::fontManager->font( "Mono", static_cast(FontSize), ghoul::fontrendering::FontManager::Outline::Yes, @@ -393,7 +393,7 @@ void RenderableDUMeshes::deinitializeGL() { DigitalUniverseModule::ProgramObjectManager.release( ProgramObjectName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); } @@ -424,7 +424,7 @@ void RenderableDUMeshes::renderMeshes(const RenderData&, case Wire: glLineWidth(_lineWidth); glDrawArrays(GL_LINE_STRIP, 0, pair.second.numV); - global::renderEngine.openglStateCache().resetLineState(); + global::renderEngine->openglStateCache().resetLineState(); break; case Point: glDrawArrays(GL_POINTS, 0, pair.second.numV); @@ -439,8 +439,8 @@ void RenderableDUMeshes::renderMeshes(const RenderData&, _program->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().resetDepthState(); - global::renderEngine.openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetDepthState(); + global::renderEngine->openglStateCache().resetBlendState(); } void RenderableDUMeshes::renderLabels(const RenderData& data, diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.cpp b/modules/digitaluniverse/rendering/renderableplanescloud.cpp index bf103c7920..04aaa90d06 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.cpp +++ b/modules/digitaluniverse/rendering/renderableplanescloud.cpp @@ -494,7 +494,7 @@ void RenderablePlanesCloud::initializeGL() { _program = DigitalUniverseModule::ProgramObjectManager.request( ProgramObjectName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( "RenderablePlanesCloud", absPath("${MODULE_DIGITALUNIVERSE}/shaders/plane_vs.glsl"), absPath("${MODULE_DIGITALUNIVERSE}/shaders/plane_fs.glsl") @@ -511,7 +511,7 @@ void RenderablePlanesCloud::initializeGL() { if (_hasLabel) { if (!_font) { constexpr const int FontSize = 30; - _font = global::fontManager.font( + _font = global::fontManager->font( "Mono", static_cast(FontSize), ghoul::fontrendering::FontManager::Outline::Yes, @@ -537,7 +537,7 @@ void RenderablePlanesCloud::deinitializeGL() { DigitalUniverseModule::ProgramObjectManager.release( ProgramObjectName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); } @@ -590,8 +590,8 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&, _program->deactivate(); // Restores OpenGL Rendering State - global::renderEngine.openglStateCache().resetBlendState(); - global::renderEngine.openglStateCache().resetDepthState(); + global::renderEngine->openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetDepthState(); } void RenderablePlanesCloud::renderLabels(const RenderData& data, diff --git a/modules/digitaluniverse/rendering/renderablepoints.cpp b/modules/digitaluniverse/rendering/renderablepoints.cpp index 7b5bca997f..ebfc9fff45 100644 --- a/modules/digitaluniverse/rendering/renderablepoints.cpp +++ b/modules/digitaluniverse/rendering/renderablepoints.cpp @@ -256,7 +256,7 @@ void RenderablePoints::initializeGL() { _program = DigitalUniverseModule::ProgramObjectManager.request( "RenderablePoints Sprite", []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( "RenderablePoints Sprite", absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl"), absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_sprite_fs.glsl") @@ -268,7 +268,7 @@ void RenderablePoints::initializeGL() { _program = DigitalUniverseModule::ProgramObjectManager.request( "RenderablePoints", []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( "RenderablePoints", absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl"), absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_sprite_fs.glsl") @@ -288,7 +288,7 @@ void RenderablePoints::deinitializeGL() { DigitalUniverseModule::ProgramObjectManager.release( _program->name(), [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); diff --git a/modules/exoplanets/exoplanetsmodule_lua.inl b/modules/exoplanets/exoplanetsmodule_lua.inl index 77f7989a63..cd73664631 100644 --- a/modules/exoplanets/exoplanetsmodule_lua.inl +++ b/modules/exoplanets/exoplanetsmodule_lua.inl @@ -210,7 +210,7 @@ void createExoplanetSystem(std::string_view starName) { "}" "}"; - openspace::global::scriptEngine.queueScript( + openspace::global::scriptEngine->queueScript( "openspace.addSceneGraphNode(" + starParent + ");", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -314,7 +314,7 @@ void createExoplanetSystem(std::string_view starName) { trailResolution *= 2; } - openspace::global::scriptEngine.queueScript( + openspace::global::scriptEngine->queueScript( "openspace.addSceneGraphNode(" + planetNode + ");", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -336,7 +336,7 @@ void createExoplanetSystem(std::string_view starName) { "}" "}"; - openspace::global::scriptEngine.queueScript( + openspace::global::scriptEngine->queueScript( "openspace.addSceneGraphNode(" + planetTrailNode + ");", openspace::scripting::ScriptEngine::RemoteScripting::Yes ); @@ -380,7 +380,7 @@ void createExoplanetSystem(std::string_view starName) { "}" "}"; - openspace::global::scriptEngine.queueScript( + openspace::global::scriptEngine->queueScript( "openspace.addSceneGraphNode(" + discNode + ");", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -430,7 +430,7 @@ int removeExoplanetSystem(lua_State* L) { const std::string starNameSpeck = std::string(speckStarName(starName)); const std::string starIdentifier = createIdentifier(starNameSpeck); - openspace::global::scriptEngine.queueScript( + openspace::global::scriptEngine->queueScript( "openspace.removeSceneGraphNode('" + starIdentifier + "');", scripting::ScriptEngine::RemoteScripting::Yes ); diff --git a/modules/exoplanets/rendering/renderableorbitdisc.cpp b/modules/exoplanets/rendering/renderableorbitdisc.cpp index 150a4d0e3d..216d8c16fa 100644 --- a/modules/exoplanets/rendering/renderableorbitdisc.cpp +++ b/modules/exoplanets/rendering/renderableorbitdisc.cpp @@ -157,7 +157,7 @@ bool RenderableOrbitDisc::isReady() const { } void RenderableOrbitDisc::initializeGL() { - _shader = global::renderEngine.buildRenderProgram( + _shader = global::renderEngine->buildRenderProgram( "OrbitdiscProgram", absPath("${BASE}/modules/exoplanets/shaders/orbitdisc_vs.glsl"), absPath("${BASE}/modules/exoplanets/shaders/orbitdisc_fs.glsl") @@ -189,7 +189,7 @@ void RenderableOrbitDisc::deinitializeGL() { _textureFile = nullptr; _texture = nullptr; - global::renderEngine.removeRenderProgram(_shader.get()); + global::renderEngine->removeRenderProgram(_shader.get()); _shader = nullptr; } @@ -228,9 +228,9 @@ void RenderableOrbitDisc::render(const RenderData& data, RendererTasks&) { _shader->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().resetBlendState(); - global::renderEngine.openglStateCache().resetDepthState(); - global::renderEngine.openglStateCache().resetPolygonAndClippingState(); + global::renderEngine->openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetDepthState(); + global::renderEngine->openglStateCache().resetPolygonAndClippingState(); } void RenderableOrbitDisc::update(const UpdateData& data) { diff --git a/modules/fieldlines/rendering/renderablefieldlines.cpp b/modules/fieldlines/rendering/renderablefieldlines.cpp index b8970efb3b..e75f6de397 100644 --- a/modules/fieldlines/rendering/renderablefieldlines.cpp +++ b/modules/fieldlines/rendering/renderablefieldlines.cpp @@ -200,7 +200,7 @@ void RenderableFieldlines::initializeGL() { throw ghoul::RuntimeError("Error initializing"); } - _program = global::renderEngine.buildRenderProgram( + _program = global::renderEngine->buildRenderProgram( "Fieldline", absPath("${MODULE_FIELDLINES}/shaders/fieldline_vs.glsl"), absPath("${MODULE_FIELDLINES}/shaders/fieldline_fs.glsl"), @@ -215,7 +215,7 @@ void RenderableFieldlines::deinitializeGL() { _vertexPositionBuffer = 0; if (_program) { - global::renderEngine.removeRenderProgram(_program.get()); + global::renderEngine->removeRenderProgram(_program.get()); _program = nullptr; } } diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp index 003ec69e3c..00b57c7e3d 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp @@ -348,7 +348,7 @@ void RenderableFieldlinesSequence::initializeGL() { setupProperties(); // Setup shader program - _shaderProgram = global::renderEngine.buildRenderProgram( + _shaderProgram = global::renderEngine->buildRenderProgram( "FieldlinesSequence", absPath("${MODULE_FIELDLINESSEQUENCE}/shaders/fieldlinessequence_vs.glsl"), absPath("${MODULE_FIELDLINESSEQUENCE}/shaders/fieldlinessequence_fs.glsl") @@ -757,21 +757,21 @@ void RenderableFieldlinesSequence::definePropertyCallbackFunctions() { } _pFocusOnOriginBtn.onChange([this] { - SceneGraphNode* node = global::renderEngine.scene()->sceneGraphNode(_identifier); + SceneGraphNode* node = global::renderEngine->scene()->sceneGraphNode(_identifier); if (!node) { LWARNING(fmt::format( "Could not find a node in scenegraph called '{}'", _identifier )); return; } - global::navigationHandler.orbitalNavigator().setFocusNode( + global::navigationHandler->orbitalNavigator().setFocusNode( node->parent()->identifier() ); - global::navigationHandler.orbitalNavigator().startRetargetAnchor(); + global::navigationHandler->orbitalNavigator().startRetargetAnchor(); }); _pJumpToStartBtn.onChange([this] { - global::timeManager.setTimeNextFrame(Time(_startTimes[0])); + global::timeManager->setTimeNextFrame(Time(_startTimes[0])); }); } @@ -1027,7 +1027,7 @@ void RenderableFieldlinesSequence::deinitializeGL() { _vertexMaskingBuffer = 0; if (_shaderProgram) { - global::renderEngine.removeRenderProgram(_shaderProgram.get()); + global::renderEngine->removeRenderProgram(_shaderProgram.get()); _shaderProgram = nullptr; } @@ -1092,12 +1092,12 @@ void RenderableFieldlinesSequence::render(const RenderData& data, RendererTasks& _shaderProgram->setUniform("particleSpeed", _pFlowSpeed); _shaderProgram->setUniform( "time", - global::windowDelegate.applicationTime() * (_pFlowReversed ? -1 : 1) + global::windowDelegate->applicationTime() * (_pFlowReversed ? -1 : 1) ); bool additiveBlending = false; if (_pColorABlendEnabled) { - const auto renderer = global::renderEngine.rendererImplementation(); + const auto renderer = global::renderEngine->rendererImplementation(); const bool usingFBufferRenderer = renderer == RenderEngine::RendererImplementation::Framebuffer; diff --git a/modules/gaia/rendering/renderablegaiastars.cpp b/modules/gaia/rendering/renderablegaiastars.cpp index a67a1d17c2..ff10f2a3f1 100644 --- a/modules/gaia/rendering/renderablegaiastars.cpp +++ b/modules/gaia/rendering/renderablegaiastars.cpp @@ -888,7 +888,7 @@ void RenderableGaiaStars::initializeGL() { _uniformCache.valuesPerStar = _program->uniformLocation("valuesPerStar"); _uniformCache.nChunksToRender = _program->uniformLocation("nChunksToRender"); - _programTM = global::renderEngine.buildRenderProgram( + _programTM = global::renderEngine->buildRenderProgram( "ToneMapping", absPath("${MODULE_GAIA}/shaders/gaia_tonemapping_vs.glsl"), absPath("${MODULE_GAIA}/shaders/gaia_tonemapping_point_fs.glsl") @@ -913,7 +913,7 @@ void RenderableGaiaStars::initializeGL() { absPath("${MODULE_GAIA}/shaders/gaia_point_ge.glsl") ); - _programTM = global::renderEngine.buildRenderProgram("ToneMapping", + _programTM = global::renderEngine->buildRenderProgram("ToneMapping", absPath("${MODULE_GAIA}/shaders/gaia_tonemapping_vs.glsl"), absPath("${MODULE_GAIA}/shaders/gaia_tonemapping_point_fs.glsl") ); @@ -950,7 +950,7 @@ void RenderableGaiaStars::initializeGL() { _uniformCache.valuesPerStar = _program->uniformLocation("valuesPerStar"); _uniformCache.nChunksToRender = _program->uniformLocation("nChunksToRender"); - _programTM = global::renderEngine.buildRenderProgram( + _programTM = global::renderEngine->buildRenderProgram( "ToneMapping", absPath("${MODULE_GAIA}/shaders/gaia_tonemapping_vs.glsl"), absPath("${MODULE_GAIA}/shaders/gaia_tonemapping_billboard_fs.glsl") @@ -964,7 +964,7 @@ void RenderableGaiaStars::initializeGL() { break; } case gaia::ShaderOption::Billboard_SSBO_noFBO: { - _program = global::renderEngine.buildRenderProgram("GaiaStar", + _program = global::renderEngine->buildRenderProgram("GaiaStar", absPath("${MODULE_GAIA}/shaders/gaia_ssbo_vs.glsl"), absPath("${MODULE_GAIA}/shaders/gaia_billboard_nofbo_fs.glsl"), absPath("${MODULE_GAIA}/shaders/gaia_billboard_ge.glsl") @@ -1006,7 +1006,7 @@ void RenderableGaiaStars::initializeGL() { ); _uniformCache.psfTexture = _program->uniformLocation("psfTexture"); - _programTM = global::renderEngine.buildRenderProgram("ToneMapping", + _programTM = global::renderEngine->buildRenderProgram("ToneMapping", absPath("${MODULE_GAIA}/shaders/gaia_tonemapping_vs.glsl"), absPath("${MODULE_GAIA}/shaders/gaia_tonemapping_billboard_fs.glsl") ); @@ -1124,11 +1124,11 @@ void RenderableGaiaStars::deinitializeGL() { _fboTexture = nullptr; if (_program) { - global::renderEngine.removeRenderProgram(_program.get()); + global::renderEngine->removeRenderProgram(_program.get()); _program = nullptr; } if (_programTM) { - global::renderEngine.removeRenderProgram(_programTM.get()); + global::renderEngine->removeRenderProgram(_programTM.get()); _programTM = nullptr; } } @@ -1149,7 +1149,7 @@ void RenderableGaiaStars::render(const RenderData& data, RendererTasks&) { glm::dmat4 projection = data.camera.projectionMatrix(); glm::dmat4 modelViewProjMat = projection * view * model; - glm::vec2 screenSize = glm::vec2(global::renderEngine.renderingResolution()); + glm::vec2 screenSize = glm::vec2(global::renderEngine->renderingResolution()); // Wait until camera has stabilized before we traverse the Octree/stream from files. const double rotationDiff = abs(length(_previousCameraRotation) - @@ -1593,7 +1593,7 @@ void RenderableGaiaStars::update(const UpdateData&) { absPath("${MODULE_GAIA}/shaders/gaia_point_ge.glsl") ); if (_program) { - global::renderEngine.removeRenderProgram(_program.get()); + global::renderEngine->removeRenderProgram(_program.get()); } _program = std::move(program); @@ -1656,7 +1656,7 @@ void RenderableGaiaStars::update(const UpdateData&) { absPath("${MODULE_GAIA}/shaders/gaia_point_ge.glsl") ); if (_program) { - global::renderEngine.removeRenderProgram(_program.get()); + global::renderEngine->removeRenderProgram(_program.get()); } _program = std::move(program); @@ -1699,7 +1699,7 @@ void RenderableGaiaStars::update(const UpdateData&) { ); } else { - program = global::renderEngine.buildRenderProgram("GaiaStar", + program = global::renderEngine->buildRenderProgram("GaiaStar", absPath("${MODULE_GAIA}/shaders/gaia_ssbo_vs.glsl"), absPath("${MODULE_GAIA}/shaders/gaia_billboard_nofbo_fs.glsl"), absPath("${MODULE_GAIA}/shaders/gaia_billboard_ge.glsl") @@ -1707,7 +1707,7 @@ void RenderableGaiaStars::update(const UpdateData&) { } if (_program) { - global::renderEngine.removeRenderProgram(_program.get()); + global::renderEngine->removeRenderProgram(_program.get()); } _program = std::move(program); @@ -1781,7 +1781,7 @@ void RenderableGaiaStars::update(const UpdateData&) { absPath("${MODULE_GAIA}/shaders/gaia_billboard_ge.glsl") ); if (_program) { - global::renderEngine.removeRenderProgram(_program.get()); + global::renderEngine->removeRenderProgram(_program.get()); } _program = std::move(program); @@ -1851,13 +1851,13 @@ void RenderableGaiaStars::update(const UpdateData&) { case gaia::ShaderOption::Point_SSBO: case gaia::ShaderOption::Point_VBO: { std::unique_ptr programTM = - global::renderEngine.buildRenderProgram( + global::renderEngine->buildRenderProgram( "ToneMapping", absPath("${MODULE_GAIA}/shaders/gaia_tonemapping_vs.glsl"), absPath("${MODULE_GAIA}/shaders/gaia_tonemapping_point_fs.glsl") ); if (_programTM) { - global::renderEngine.removeRenderProgram(_programTM.get()); + global::renderEngine->removeRenderProgram(_programTM.get()); } _programTM = std::move(programTM); @@ -1879,9 +1879,9 @@ void RenderableGaiaStars::update(const UpdateData&) { "${MODULE_GAIA}/shaders/gaia_tonemapping_billboard_fs.glsl" ); std::unique_ptr programTM = - global::renderEngine.buildRenderProgram("ToneMapping", vs, fs); + global::renderEngine->buildRenderProgram("ToneMapping", vs, fs); if (_programTM) { - global::renderEngine.removeRenderProgram(_programTM.get()); + global::renderEngine->removeRenderProgram(_programTM.get()); } _programTM = std::move(programTM); break; @@ -2236,7 +2236,7 @@ void RenderableGaiaStars::update(const UpdateData&) { } if (!_fboTexture) { // Generate a new texture and attach it to our FBO. - glm::vec2 screenSize = glm::vec2(global::renderEngine.renderingResolution()); + glm::vec2 screenSize = glm::vec2(global::renderEngine->renderingResolution()); _fboTexture = std::make_unique( glm::uvec3(screenSize, 1), ghoul::opengl::Texture::Format::RGBA, @@ -2321,9 +2321,9 @@ void RenderableGaiaStars::update(const UpdateData&) { _colorTextureIsDirty = false; } - if (global::windowDelegate.windowHasResized()) { + if (global::windowDelegate->windowHasResized()) { // Update FBO texture resolution if we haven't already. - glm::vec2 screenSize = glm::vec2(global::renderEngine.renderingResolution()); + glm::vec2 screenSize = glm::vec2(global::renderEngine->renderingResolution()); const bool hasChanged = glm::any( glm::notEqual(_fboTexture->dimensions(), glm::uvec3(screenSize, 1)) ); diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index d7cbfc22e4..34cf343446 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -356,10 +356,10 @@ RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary) auto onChange = [&](bool enabled) { if (enabled) { - global::raycasterManager.attachRaycaster(*_raycaster); + global::raycasterManager->attachRaycaster(*_raycaster); } else { - global::raycasterManager.detachRaycaster(*_raycaster); + global::raycasterManager->detachRaycaster(*_raycaster); } }; @@ -464,19 +464,19 @@ void RenderableGalaxy::initializeGL() { // We no longer need the data _volume = nullptr; - global::raycasterManager.attachRaycaster(*_raycaster); + global::raycasterManager->attachRaycaster(*_raycaster); // initialize points. if (_pointsFilename.empty()) { return; } - _pointsProgram = global::renderEngine.buildRenderProgram( + _pointsProgram = global::renderEngine->buildRenderProgram( "Galaxy points", absPath("${MODULE_GALAXY}/shaders/points_vs.glsl"), absPath("${MODULE_GALAXY}/shaders/points_fs.glsl") ); - _billboardsProgram = global::renderEngine.buildRenderProgram( + _billboardsProgram = global::renderEngine->buildRenderProgram( "Galaxy billboard", absPath("${MODULE_GALAXY}/shaders/billboard_vs.glsl"), absPath("${MODULE_GALAXY}/shaders/billboard_fs.glsl"), @@ -557,7 +557,7 @@ void RenderableGalaxy::initializeGL() { void RenderableGalaxy::deinitializeGL() { if (_raycaster) { - global::raycasterManager.detachRaycaster(*_raycaster); + global::raycasterManager->detachRaycaster(*_raycaster); _raycaster = nullptr; } @@ -716,8 +716,8 @@ void RenderableGalaxy::renderPoints(const RenderData& data) { _pointsProgram->deactivate(); // Restores OpenGL Rendering State - global::renderEngine.openglStateCache().resetBlendState(); - global::renderEngine.openglStateCache().resetDepthState(); + global::renderEngine->openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetDepthState(); } void RenderableGalaxy::renderBillboards(const RenderData& data) { diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index 89972ee1fb..e7e36ddaa1 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -511,7 +511,7 @@ void GlobeBrowsingModule::goToChunk(const globebrowsing::RenderableGlobe& globe, }; // Compute altitude - const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3(); + const glm::dvec3 cameraPosition = global::navigationHandler->camera()->positionVec3(); SceneGraphNode* globeSceneGraphNode = dynamic_cast(globe.owner()); if (!globeSceneGraphNode) { LERROR( @@ -545,7 +545,7 @@ void GlobeBrowsingModule::goToGeodetic2(const globebrowsing::RenderableGlobe& gl { using namespace globebrowsing; - const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3(); + const glm::dvec3 cameraPosition = global::navigationHandler->camera()->positionVec3(); SceneGraphNode* globeSceneGraphNode = dynamic_cast(globe.owner()); if (!globeSceneGraphNode) { LERROR("Error when going to Geodetic2"); @@ -585,7 +585,7 @@ void GlobeBrowsingModule::goToGeodetic3(const globebrowsing::RenderableGlobe& gl state.position = positionModelSpace; state.up = slightlyNorth; - global::navigationHandler.setNavigationStateNextFrame(state); + global::navigationHandler->setNavigationStateNextFrame(state); } glm::dquat GlobeBrowsingModule::lookDownCameraRotation( @@ -624,7 +624,7 @@ GlobeBrowsingModule::castFocusNodeRenderableToGlobe() using namespace globebrowsing; const Renderable* renderable = - global::navigationHandler.orbitalNavigator().anchorNode()->renderable(); + global::navigationHandler->orbitalNavigator().anchorNode()->renderable(); if (!renderable) { return nullptr; diff --git a/modules/globebrowsing/globebrowsingmodule_lua.inl b/modules/globebrowsing/globebrowsingmodule_lua.inl index 5f091b8108..8bd0fb47a3 100644 --- a/modules/globebrowsing/globebrowsingmodule_lua.inl +++ b/modules/globebrowsing/globebrowsingmodule_lua.inl @@ -53,7 +53,7 @@ int addLayer(lua_State* L) { const std::string& layerGroupName = ghoul::lua::value(L, 2); // Get the node and make sure it exists - SceneGraphNode* n = global::renderEngine.scene()->sceneGraphNode(globeName); + SceneGraphNode* n = global::renderEngine->scene()->sceneGraphNode(globeName); if (!n) { return ghoul::lua::luaError(L, "Unknown globe name: " + globeName); } @@ -105,7 +105,7 @@ int deleteLayer(lua_State* L) { lua_pop(L, 3); // Get the node and make sure it exists - SceneGraphNode* n = global::renderEngine.scene()->sceneGraphNode(globeName); + SceneGraphNode* n = global::renderEngine->scene()->sceneGraphNode(globeName); if (!n) { return ghoul::lua::luaError(L, "Unknown globe name: " + globeName); } @@ -220,7 +220,7 @@ int goToChunk(lua_State* L) { return ghoul::lua::luaError(L, "Identifier must be a RenderableGlobe"); } - global::moduleEngine.module()->goToChunk(*globe, x, y, level); + global::moduleEngine->module()->goToChunk(*globe, x, y, level); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -243,7 +243,7 @@ int goToGeo(lua_State* L) { } } else { - n = global::navigationHandler.orbitalNavigator().anchorNode(); + n = global::navigationHandler->orbitalNavigator().anchorNode(); if (!n) { return ghoul::lua::luaError(L, "No anchor node is set."); } @@ -267,13 +267,13 @@ int goToGeo(lua_State* L) { } if (nArguments == parameterOffset + 2) { - global::moduleEngine.module()->goToGeo( + global::moduleEngine->module()->goToGeo( *globe, latitude, longitude ); } else if (nArguments == parameterOffset + 3) { const double altitude = ghoul::lua::value(L, parameterOffset + 3); - global::moduleEngine.module()->goToGeo( + global::moduleEngine->module()->goToGeo( *globe, latitude, longitude, @@ -305,7 +305,7 @@ int getGeoPosition(lua_State* L) { return ghoul::lua::luaError(L, "Identifier must be a RenderableGlobe"); } - GlobeBrowsingModule& mod = *(global::moduleEngine.module()); + GlobeBrowsingModule& mod = *(global::moduleEngine->module()); glm::vec3 pos = mod.cartesianCoordinatesFromGeo( *globe, latitude, @@ -322,15 +322,15 @@ int getGeoPosition(lua_State* L) { int getGeoPositionForCamera(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::getGeoPositionForCamera"); - GlobeBrowsingModule* module = global::moduleEngine.module(); + GlobeBrowsingModule* module = global::moduleEngine->module(); const RenderableGlobe* globe = module->castFocusNodeRenderableToGlobe(); if (!globe) { return ghoul::lua::luaError(L, "Focus node must be a RenderableGlobe"); } - const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3(); + const glm::dvec3 cameraPosition = global::navigationHandler->camera()->positionVec3(); const SceneGraphNode* anchor = - global::navigationHandler.orbitalNavigator().anchorNode(); + global::navigationHandler->orbitalNavigator().anchorNode(); const glm::dmat4 inverseModelTransform = glm::inverse(anchor->modelTransform()); const glm::dvec3 cameraPositionModelSpace = glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0)); @@ -357,7 +357,7 @@ int loadWMSCapabilities(lua_State* L) { std::string globe = ghoul::lua::value(L, 2); std::string url = ghoul::lua::value(L, 3); - global::moduleEngine.module()->loadWMSCapabilities( + global::moduleEngine->module()->loadWMSCapabilities( std::move(name), std::move(globe), std::move(url) @@ -378,7 +378,7 @@ int removeWMSServer(lua_State* L) { ghoul::lua::PopValue::Yes ); - global::moduleEngine.module()->removeWMSServer(name); + global::moduleEngine->module()->removeWMSServer(name); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -393,7 +393,7 @@ int capabilities(lua_State* L) { ghoul::lua::PopValue::Yes ); GlobeBrowsingModule::Capabilities cap = - global::moduleEngine.module()->capabilities(name); + global::moduleEngine->module()->capabilities(name); lua_newtable(L); for (unsigned long i = 0; i < cap.size(); ++i) { diff --git a/modules/globebrowsing/src/asynctiledataprovider.cpp b/modules/globebrowsing/src/asynctiledataprovider.cpp index 0f1a949ee8..98f0e35161 100644 --- a/modules/globebrowsing/src/asynctiledataprovider.cpp +++ b/modules/globebrowsing/src/asynctiledataprovider.cpp @@ -48,7 +48,7 @@ AsyncTileDataProvider::AsyncTileDataProvider(std::string name, { ZoneScoped - _globeBrowsingModule = global::moduleEngine.module(); + _globeBrowsingModule = global::moduleEngine->module(); performReset(ResetRawTileDataReader::No); } diff --git a/modules/globebrowsing/src/dashboarditemglobelocation.cpp b/modules/globebrowsing/src/dashboarditemglobelocation.cpp index a696958163..cd19cfb440 100644 --- a/modules/globebrowsing/src/dashboarditemglobelocation.cpp +++ b/modules/globebrowsing/src/dashboarditemglobelocation.cpp @@ -105,7 +105,7 @@ DashboardItemGlobeLocation::DashboardItemGlobeLocation( , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 10.f, 144.f, 1.f) , _significantDigits(SignificantDigitsInfo, 4, 1, 12) - , _font(global::fontManager.font(KeyFontMono, 10)) + , _font(global::fontManager->font(KeyFontMono, 10)) { documentation::testSpecificationAndThrow( Documentation(), @@ -127,12 +127,12 @@ DashboardItemGlobeLocation::DashboardItemGlobeLocation( _fontName.onChange([this]() { - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontName); _fontSize.onChange([this]() { - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontSize); @@ -148,7 +148,7 @@ DashboardItemGlobeLocation::DashboardItemGlobeLocation( addProperty(_significantDigits); updateFormatString(); - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); _buffer.resize(128); } @@ -157,7 +157,7 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) { using namespace globebrowsing; - const SceneGraphNode* n = global::navigationHandler.orbitalNavigator().anchorNode(); + const SceneGraphNode* n = global::navigationHandler->orbitalNavigator().anchorNode(); if (!n) { return; } @@ -166,7 +166,7 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) { return; } - const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3(); + const glm::dvec3 cameraPosition = global::navigationHandler->camera()->positionVec3(); const glm::dmat4 inverseModelTransform = glm::inverse(n->modelTransform()); const glm::dvec3 cameraPositionModelSpace = glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0)); diff --git a/modules/globebrowsing/src/gdalwrapper.cpp b/modules/globebrowsing/src/gdalwrapper.cpp index f8992d84d1..054f3786fe 100644 --- a/modules/globebrowsing/src/gdalwrapper.cpp +++ b/modules/globebrowsing/src/gdalwrapper.cpp @@ -132,12 +132,12 @@ GdalWrapper::GdalWrapper(size_t maximumCacheSize, size_t maximumMaximumCacheSize } void GdalWrapper::setGdalProxyConfiguration() { - if (global::configuration.httpProxy.usingHttpProxy) { - const std::string address = global::configuration.httpProxy.address; - const unsigned int port = global::configuration.httpProxy.port; - const std::string user = global::configuration.httpProxy.user; - const std::string password = global::configuration.httpProxy.password; - std::string auth = global::configuration.httpProxy.authentication; + if (global::configuration->httpProxy.usingHttpProxy) { + const std::string address = global::configuration->httpProxy.address; + const unsigned int port = global::configuration->httpProxy.port; + const std::string user = global::configuration->httpProxy.user; + const std::string password = global::configuration->httpProxy.password; + std::string auth = global::configuration->httpProxy.authentication; std::transform( auth.begin(), auth.end(), diff --git a/modules/globebrowsing/src/globelabelscomponent.cpp b/modules/globebrowsing/src/globelabelscomponent.cpp index a603733eaf..2eb2e0f97e 100644 --- a/modules/globebrowsing/src/globelabelscomponent.cpp +++ b/modules/globebrowsing/src/globelabelscomponent.cpp @@ -444,7 +444,7 @@ void GlobeLabelsComponent::initialize(const ghoul::Dictionary& dictionary, } void GlobeLabelsComponent::initializeFonts() { - _font = openspace::global::fontManager.font( + _font = openspace::global::fontManager->font( "Mono", static_cast(_labelsFontSize), ghoul::fontrendering::FontManager::Outline::Yes, @@ -562,7 +562,7 @@ bool GlobeLabelsComponent::readLabelsFile(const std::string& file) { strncpy(lEntry.feature, token.c_str(), 256); GlobeBrowsingModule* _globeBrowsingModule = - global::moduleEngine.module(); + global::moduleEngine->module(); lEntry.geoPosition = _globeBrowsingModule->cartesianCoordinatesFromGeo( *_globe, lEntry.latitude, diff --git a/modules/globebrowsing/src/globetranslation.cpp b/modules/globebrowsing/src/globetranslation.cpp index 708f3ed0b1..8317d7c65a 100644 --- a/modules/globebrowsing/src/globetranslation.cpp +++ b/modules/globebrowsing/src/globetranslation.cpp @@ -205,7 +205,7 @@ glm::dvec3 GlobeTranslation::position(const UpdateData&) const { return _position; } - GlobeBrowsingModule& mod = *(global::moduleEngine.module()); + GlobeBrowsingModule& mod = *(global::moduleEngine->module()); if (_useHeightmap) { glm::vec3 groundPos = mod.cartesianCoordinatesFromGeo( diff --git a/modules/globebrowsing/src/rawtiledatareader.cpp b/modules/globebrowsing/src/rawtiledatareader.cpp index 4463afb88b..bbbee1d771 100644 --- a/modules/globebrowsing/src/rawtiledatareader.cpp +++ b/modules/globebrowsing/src/rawtiledatareader.cpp @@ -444,7 +444,7 @@ void RawTileDataReader::initialize() { throw ghoul::RuntimeError("File path must not be empty"); } - GlobeBrowsingModule& module = *global::moduleEngine.module(); + GlobeBrowsingModule& module = *global::moduleEngine->module(); std::string content = _datasetFilePath; if (module.isWMSCachingEnabled()) { diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 4ea6fb38e7..0c774885df 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -284,7 +284,7 @@ ChunkTileVector tilesAndSettingsUnsorted(const LayerGroup& layerGroup, #if defined(__APPLE__) || (defined(__linux__) && defined(__clang__)) ChunkTileVector tilesAndSettings; #else - ChunkTileVector tilesAndSettings(&global::memoryManager.TemporaryMemory); + ChunkTileVector tilesAndSettings(&global::memoryManager->TemporaryMemory); #endif for (Layer* layer : layerGroup.activeLayers()) { if (layer->tileProvider()) { @@ -764,12 +764,12 @@ void RenderableGlobe::deinitialize() { void RenderableGlobe::deinitializeGL() { if (_localRenderer.program) { - global::renderEngine.removeRenderProgram(_localRenderer.program.get()); + global::renderEngine->removeRenderProgram(_localRenderer.program.get()); _localRenderer.program = nullptr; } if (_globalRenderer.program) { - global::renderEngine.removeRenderProgram(_globalRenderer.program.get()); + global::renderEngine->removeRenderProgram(_globalRenderer.program.get()); _globalRenderer.program = nullptr; } @@ -1813,8 +1813,8 @@ void RenderableGlobe::recompileShaders() { // // Create local shader // - global::renderEngine.removeRenderProgram(_localRenderer.program.get()); - _localRenderer.program = global::renderEngine.buildRenderProgram( + global::renderEngine->removeRenderProgram(_localRenderer.program.get()); + _localRenderer.program = global::renderEngine->buildRenderProgram( "LocalChunkedLodPatch", absPath("${MODULE_GLOBEBROWSING}/shaders/localrenderer_vs.glsl"), absPath("${MODULE_GLOBEBROWSING}/shaders/renderer_fs.glsl"), @@ -1842,8 +1842,8 @@ void RenderableGlobe::recompileShaders() { // // Create global shader // - global::renderEngine.removeRenderProgram(_globalRenderer.program.get()); - _globalRenderer.program = global::renderEngine.buildRenderProgram( + global::renderEngine->removeRenderProgram(_globalRenderer.program.get()); + _globalRenderer.program = global::renderEngine->buildRenderProgram( "GlobalChunkedLodPatch", absPath("${MODULE_GLOBEBROWSING}/shaders/globalrenderer_vs.glsl"), absPath("${MODULE_GLOBEBROWSING}/shaders/renderer_fs.glsl"), @@ -2128,9 +2128,11 @@ void RenderableGlobe::calculateEclipseShadows(ghoul::opengl::ProgramObject& prog casterPos *= KM_TO_M; // converting to meters const std::string source = shadowConf.source.first; - SceneGraphNode* sourceNode = global::renderEngine.scene()->sceneGraphNode(source); + SceneGraphNode* sourceNode = + global::renderEngine->scene()->sceneGraphNode(source); const std::string caster = shadowConf.caster.first; - SceneGraphNode* casterNode = global::renderEngine.scene()->sceneGraphNode(caster); + SceneGraphNode* casterNode = + global::renderEngine->scene()->sceneGraphNode(caster); const double sourceRadiusScale = std::max( glm::compMax(sourceNode->scale()), diff --git a/modules/globebrowsing/src/ringscomponent.cpp b/modules/globebrowsing/src/ringscomponent.cpp index 6cec19f313..53f0e08ec9 100644 --- a/modules/globebrowsing/src/ringscomponent.cpp +++ b/modules/globebrowsing/src/ringscomponent.cpp @@ -265,7 +265,7 @@ void RingsComponent::initializeGL() { try { //global::renderEngine.removeRenderProgram(_geometryOnlyShader.get()); - _geometryOnlyShader = global::renderEngine.buildRenderProgram( + _geometryOnlyShader = global::renderEngine->buildRenderProgram( "RingsGeomOnlyProgram", absPath("${MODULE_GLOBEBROWSING}/shaders/rings_geom_vs.glsl"), absPath("${MODULE_GLOBEBROWSING}/shaders/rings_geom_fs.glsl") @@ -298,10 +298,10 @@ void RingsComponent::deinitializeGL() { _textureFile = nullptr; _texture = nullptr; - global::renderEngine.removeRenderProgram(_shader.get()); + global::renderEngine->removeRenderProgram(_shader.get()); _shader = nullptr; - global::renderEngine.removeRenderProgram(_geometryOnlyShader.get()); + global::renderEngine->removeRenderProgram(_geometryOnlyShader.get()); _geometryOnlyShader = nullptr; } @@ -410,7 +410,7 @@ void RingsComponent::update(const UpdateData& data) { } _sunPosition = glm::normalize( - global::renderEngine.scene()->sceneGraphNode("Sun")->worldPosition() - + global::renderEngine->scene()->sceneGraphNode("Sun")->worldPosition() - data.modelTransform.translation ); } @@ -488,8 +488,8 @@ void RingsComponent::compileShadowShader() { dict.setValue("nShadowSamples", std::to_string(_nShadowSamples - 1)); try { - global::renderEngine.removeRenderProgram(_shader.get()); - _shader = global::renderEngine.buildRenderProgram( + global::renderEngine->removeRenderProgram(_shader.get()); + _shader = global::renderEngine->buildRenderProgram( "RingsProgram", absPath("${MODULE_GLOBEBROWSING}/shaders/rings_vs.glsl"), absPath("${MODULE_GLOBEBROWSING}/shaders/rings_fs.glsl"), diff --git a/modules/globebrowsing/src/shadowcomponent.cpp b/modules/globebrowsing/src/shadowcomponent.cpp index 598cf1fc3a..b9615037cb 100644 --- a/modules/globebrowsing/src/shadowcomponent.cpp +++ b/modules/globebrowsing/src/shadowcomponent.cpp @@ -205,7 +205,7 @@ ShadowComponent::ShadowComponent(const ghoul::Dictionary& dictionary) _dynamicDepthTextureRes = false; } else { - glm::ivec2 renderingResolution = global::renderEngine.renderingResolution(); + glm::ivec2 renderingResolution = global::renderEngine->renderingResolution(); _shadowDepthTextureWidth = renderingResolution.x * 2; _shadowDepthTextureHeight = renderingResolution.y * 2; _dynamicDepthTextureRes = true; @@ -413,7 +413,7 @@ void ShadowComponent::end() { if (_viewDepthMap) { if (!_renderDMProgram) { - _renderDMProgram = global::renderEngine.buildRenderProgram( + _renderDMProgram = global::renderEngine->buildRenderProgram( "ShadowMappingDebuggingProgram", absPath("${MODULE_GLOBEBROWSING}/shaders/smviewer_vs.glsl"), absPath("${MODULE_GLOBEBROWSING}/shaders/smviewer_fs.glsl") @@ -442,9 +442,9 @@ void ShadowComponent::end() { void ShadowComponent::update(const UpdateData&) { ZoneScoped - _sunPosition = global::renderEngine.scene()->sceneGraphNode("Sun")->worldPosition(); + _sunPosition = global::renderEngine->scene()->sceneGraphNode("Sun")->worldPosition(); - glm::ivec2 renderingResolution = global::renderEngine.renderingResolution(); + glm::ivec2 renderingResolution = global::renderEngine->renderingResolution(); if (_dynamicDepthTextureRes && ((_shadowDepthTextureWidth != renderingResolution.x) || (_shadowDepthTextureHeight != renderingResolution.y))) { diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index 2c2cde681b..a8fa393b0e 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -191,7 +191,7 @@ bool initTexturesFromLoadedData(DefaultTileProvider& t) { void initialize(TextTileProvider& t) { ZoneScoped - t.font = global::fontManager.font("Mono", static_cast(t.fontSize)); + t.font = global::fontManager->font("Mono", static_cast(t.fontSize)); t.fontRenderer = ghoul::fontrendering::FontRenderer::createDefault(); t.fontRenderer->setFramebufferSize(glm::vec2(t.initData.dimensions)); glGenFramebuffers(1, &t.fbo); @@ -235,7 +235,7 @@ Tile tile(TextTileProvider& t, const TileIndex& tileIndex) { t.fontRenderer->render(*t.font, t.textPosition, t.text, t.textColor); glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - global::renderEngine.openglStateCache().resetViewportState(); + global::renderEngine->openglStateCache().resetViewportState(); //glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); tile = Tile{ texture, std::nullopt, Tile::Status::OK }; @@ -556,7 +556,7 @@ DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary) type = Type::DefaultTileProvider; - tileCache = global::moduleEngine.module()->tileCache(); + tileCache = global::moduleEngine->module()->tileCache(); name = "Name unspecified"; if (dictionary.hasKeyAndValue("Name")) { name = dictionary.value("Name"); @@ -635,7 +635,7 @@ TextTileProvider::TextTileProvider(TileTextureInitData initData, size_t fontSize { ZoneScoped - tileCache = global::moduleEngine.module()->tileCache(); + tileCache = global::moduleEngine->module()->tileCache(); } @@ -649,7 +649,7 @@ SizeReferenceTileProvider::SizeReferenceTileProvider(const ghoul::Dictionary& di type = Type::SizeReferenceTileProvider; - font = global::fontManager.font("Mono", static_cast(fontSize)); + font = global::fontManager->font("Mono", static_cast(fontSize)); if (dictionary.hasKeyAndValue(sizereferenceprovider::KeyRadii)) { ellipsoid = dictionary.value(sizereferenceprovider::KeyRadii); @@ -1220,9 +1220,9 @@ int update(TileProvider& tp) { case Type::TemporalTileProvider: { TemporalTileProvider& t = static_cast(tp); if (t.successfulInitialization) { - TileProvider* newCurrent = getTileProvider(t, global::timeManager.time()); - if (newCurrent) { - t.currentTileProvider = newCurrent; + TileProvider* newCurr = getTileProvider(t, global::timeManager->time()); + if (newCurr) { + t.currentTileProvider = newCurr; } if (t.currentTileProvider) { update(*t.currentTileProvider); diff --git a/modules/imgui/imguimodule.cpp b/modules/imgui/imguimodule.cpp index 7cc9fd6fab..50bc8dbe78 100644 --- a/modules/imgui/imguimodule.cpp +++ b/modules/imgui/imguimodule.cpp @@ -51,13 +51,13 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { gui._globalProperty.setSource( []() { std::vector res = { - &global::navigationHandler, - &global::sessionRecording, - &global::timeManager, - &global::renderEngine, - &global::parallelPeer, - &global::luaConsole, - &global::dashboard + global::navigationHandler, + global::sessionRecording, + global::timeManager, + global::renderEngine, + global::parallelPeer, + global::luaConsole, + global::dashboard }; return res; } @@ -65,21 +65,21 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { gui._screenSpaceProperty.setSource( []() { - return global::screenSpaceRootPropertyOwner.propertySubOwners(); + return global::screenSpaceRootPropertyOwner->propertySubOwners(); } ); gui._moduleProperty.setSource( []() { std::vector v; - v.push_back(&(global::moduleEngine)); + v.push_back(global::moduleEngine); return v; } ); gui._sceneProperty.setSource( []() { - const Scene* scene = global::renderEngine.scene(); + const Scene* scene = global::renderEngine->scene(); const std::vector& nodes = scene ? scene->allSceneGraphNodes() : std::vector(); @@ -94,7 +94,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { gui._virtualProperty.setSource( []() { std::vector res = { - &global::virtualPropertyManager + global::virtualPropertyManager }; return res; @@ -104,7 +104,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { gui._featuredProperties.setSource( []() { std::vector nodes = - global::renderEngine.scene()->allSceneGraphNodes(); + global::renderEngine->scene()->allSceneGraphNodes(); nodes.erase( std::remove_if( @@ -154,7 +154,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { global::callback::draw2D.emplace_back([&]() { ZoneScopedN("ImGUI") - WindowDelegate& delegate = global::windowDelegate; + WindowDelegate& delegate = *global::windowDelegate; const bool showGui = delegate.hasGuiWindow() ? delegate.isGuiWindow() : true; if (delegate.isMaster() && showGui) { const glm::ivec2 windowSize = delegate.currentSubwindowSize(); diff --git a/modules/imgui/src/gui.cpp b/modules/imgui/src/gui.cpp index d9b4ed4bc2..85868ef5c3 100644 --- a/modules/imgui/src/gui.cpp +++ b/modules/imgui/src/gui.cpp @@ -82,7 +82,7 @@ namespace { ); } - openspace::global::scriptEngine.queueScript( + openspace::global::scriptEngine->queueScript( script, openspace::scripting::ScriptEngine::RemoteScripting::Yes ); @@ -113,7 +113,7 @@ namespace { ); } - openspace::global::scriptEngine.queueScript( + openspace::global::scriptEngine->queueScript( script, openspace::scripting::ScriptEngine::RemoteScripting::Yes ); @@ -222,7 +222,7 @@ void GUI::initializeGL() { strcpy(iniFileBuffer, cachedFile.c_str()); #endif - int nWindows = global::windowDelegate.nWindows(); + int nWindows = global::windowDelegate->nWindows(); _contexts.resize(nWindows); for (int i = 0; i < nWindows; ++i) { @@ -420,7 +420,7 @@ void GUI::startFrame(float deltaTime, const glm::vec2& windowSize, const glm::vec2& dpiScaling, const glm::vec2& mousePos, uint32_t mouseButtonsPressed) { - const int iWindow = global::windowDelegate.currentWindowId(); + const int iWindow = global::windowDelegate->currentWindowId(); ImGui::SetCurrentContext(_contexts[iWindow]); ImGuiIO& io = ImGui::GetIO(); @@ -752,7 +752,7 @@ void GUI::render() { bool addDashboard = ImGui::Button("Add New Dashboard"); if (addDashboard) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.addScreenSpaceRenderable({ Type = 'ScreenSpaceDashboard' });", openspace::scripting::ScriptEngine::RemoteScripting::Yes ); @@ -760,7 +760,7 @@ void GUI::render() { bool addDashboardCopy = ImGui::Button("Add Copy of Main Dashboard"); if (addDashboardCopy) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.addScreenSpaceRenderable({ " "Type = 'ScreenSpaceDashboard', UseMainDashboard = true " "});", diff --git a/modules/imgui/src/guiassetcomponent.cpp b/modules/imgui/src/guiassetcomponent.cpp index 0ccf5fa399..7ab2c37365 100644 --- a/modules/imgui/src/guiassetcomponent.cpp +++ b/modules/imgui/src/guiassetcomponent.cpp @@ -74,7 +74,7 @@ void GuiAssetComponent::render() { ImGui::Begin("Assets", &e); _isEnabled = e; - AssetManager& assetManager = global::openSpaceEngine.assetManager(); + AssetManager& assetManager = global::openSpaceEngine->assetManager(); std::string rootPath; diff --git a/modules/imgui/src/guigibscomponent.cpp b/modules/imgui/src/guigibscomponent.cpp index acdde9ea70..779cf00de6 100644 --- a/modules/imgui/src/guigibscomponent.cpp +++ b/modules/imgui/src/guigibscomponent.cpp @@ -122,7 +122,7 @@ void GuiGIBSComponent::render() { "FilePath = {} }})", layer, xmlFunc ); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( script, scripting::ScriptEngine::RemoteScripting::Yes ); diff --git a/modules/imgui/src/guiglobebrowsingcomponent.cpp b/modules/imgui/src/guiglobebrowsingcomponent.cpp index 5f77d49496..70a712a4f5 100644 --- a/modules/imgui/src/guiglobebrowsingcomponent.cpp +++ b/modules/imgui/src/guiglobebrowsingcomponent.cpp @@ -50,7 +50,7 @@ GuiGlobeBrowsingComponent::GuiGlobeBrowsingComponent() {} void GuiGlobeBrowsingComponent::render() { - GlobeBrowsingModule* module = global::moduleEngine.module(); + GlobeBrowsingModule* module = global::moduleEngine->module(); using UrlInfo = GlobeBrowsingModule::UrlInfo; using Capabilities = GlobeBrowsingModule::Capabilities; using Layer = GlobeBrowsingModule::Layer; @@ -66,7 +66,7 @@ void GuiGlobeBrowsingComponent::render() { // Render the list of planets std::vector nodes = - global::renderEngine.scene()->allSceneGraphNodes(); + global::renderEngine->scene()->allSceneGraphNodes(); nodes.erase( std::remove_if( @@ -127,7 +127,7 @@ void GuiGlobeBrowsingComponent::render() { // Check if the focus node is a RenderableGlobe const SceneGraphNode* const focus = - global::navigationHandler.orbitalNavigator().anchorNode(); + global::navigationHandler->orbitalNavigator().anchorNode(); const auto it = std::find(nodes.cbegin(), nodes.cend(), focus); if (it != nodes.end()) { @@ -152,7 +152,7 @@ void GuiGlobeBrowsingComponent::render() { bool selectFocusNode = ImGui::Button("From Focus"); if (selectFocusNode) { const SceneGraphNode* const focus = - global::navigationHandler.orbitalNavigator().anchorNode(); + global::navigationHandler->orbitalNavigator().anchorNode(); const auto it = std::find(nodes.cbegin(), nodes.cend(), focus); if (it != nodes.end()) { @@ -330,7 +330,7 @@ void GuiGlobeBrowsingComponent::render() { std::remove(layerName.begin(), layerName.end(), ' '), layerName.end() ); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( fmt::format( "openspace.globebrowsing.addLayer(\ '{}', \ diff --git a/modules/imgui/src/guiiswacomponent.cpp b/modules/imgui/src/guiiswacomponent.cpp index 468968de69..21a7d366c1 100644 --- a/modules/imgui/src/guiiswacomponent.cpp +++ b/modules/imgui/src/guiiswacomponent.cpp @@ -70,7 +70,7 @@ void GuiIswaComponent::render() { ImGui::InputText("addCynget", addCygnetBuffer, AddCygnetBufferSize); if (ImGui::SmallButton("Add Cygnet")) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.iswa.addCygnet(" + std::string(addCygnetBuffer) + ");", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -83,13 +83,13 @@ void GuiIswaComponent::render() { openspace.iswa.addCygnet(-5, 'Data', 'GMData'); openspace.iswa.addCygnet(-6, 'Data', 'GMData'); )"; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( script, scripting::ScriptEngine::RemoteScripting::Yes ); } else { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.iswa.removeGroup('GMData');", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -103,13 +103,13 @@ void GuiIswaComponent::render() { openspace.iswa.addCygnet(-5, 'Texture', 'GMImage'); openspace.iswa.addCygnet(-6, 'Texture', 'GMImage'); )"; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( script, scripting::ScriptEngine::RemoteScripting::Yes ); } else { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.iswa.removeGroup('GMImage');", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -118,13 +118,13 @@ void GuiIswaComponent::render() { if (_ionData != oldIonDataValue) { if (_ionData) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.iswa.addCygnet(-10, 'Data', 'Ionosphere');", scripting::ScriptEngine::RemoteScripting::Yes ); } else { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.iswa.removeGroup('Ionosphere');", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -158,7 +158,7 @@ void GuiIswaComponent::render() { const int cdfOption = _cdfOptionsMap[groupName]; if (cdfOptionValue != cdfOption) { const std::string& date = cdfs[cdfOption].date; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.iswa.addKameleonPlanes('" + cdfs[cdfOption].group + "'," + @@ -166,11 +166,11 @@ void GuiIswaComponent::render() { ");", scripting::ScriptEngine::RemoteScripting::Yes ); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.setTime('" + date + "');", scripting::ScriptEngine::RemoteScripting::Yes ); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.setDeltaTime(0);", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -201,13 +201,13 @@ void GuiIswaComponent::render() { if (selected != info.selected) { const std::string idStr = std::to_string(id); if (info.selected) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.iswa.addScreenSpaceCygnet({CygnetId=" + idStr + "});", scripting::ScriptEngine::RemoteScripting::Yes ); } else { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.iswa.removeScreenSpaceCygnet(" + idStr + ");", scripting::ScriptEngine::RemoteScripting::Yes ); diff --git a/modules/imgui/src/guijoystickcomponent.cpp b/modules/imgui/src/guijoystickcomponent.cpp index 1eb350bd22..3b4609d406 100644 --- a/modules/imgui/src/guijoystickcomponent.cpp +++ b/modules/imgui/src/guijoystickcomponent.cpp @@ -50,8 +50,8 @@ void GuiJoystickComponent::render() { _isEnabled = v; _isCollapsed = ImGui::IsWindowCollapsed(); - for (size_t i = 0; i < global::joystickInputStates.size(); ++i) { - const JoystickInputState& state = global::joystickInputStates[i]; + for (size_t i = 0; i < global::joystickInputStates->size(); ++i) { + const JoystickInputState& state = global::joystickInputStates->at(i); if (!state.isConnected) { continue; } @@ -85,7 +85,7 @@ void GuiJoystickComponent::render() { ImGui::Text("%s", "Summed contributions"); ImGui::Text("%s", "Axes"); for (int i = 0; i < JoystickInputState::MaxAxes; ++i) { - float f = global::joystickInputStates.axis(i); + float f = global::joystickInputStates->axis(i); ImGui::SliderFloat( std::to_string(i).c_str(), &f, @@ -97,8 +97,8 @@ void GuiJoystickComponent::render() { for (int i = 0; i < JoystickInputState::MaxButtons; ++i) { ImGui::RadioButton( std::to_string(i).c_str(), - global::joystickInputStates.button(i, JoystickAction::Press) || - global::joystickInputStates.button(i, JoystickAction::Repeat) + global::joystickInputStates->button(i, JoystickAction::Press) || + global::joystickInputStates->button(i, JoystickAction::Repeat) ); } diff --git a/modules/imgui/src/guimemorycomponent.cpp b/modules/imgui/src/guimemorycomponent.cpp index c1d267a4d1..04a6e6f6a4 100644 --- a/modules/imgui/src/guimemorycomponent.cpp +++ b/modules/imgui/src/guimemorycomponent.cpp @@ -64,7 +64,7 @@ void GuiMemoryComponent::render() { _isCollapsed = ImGui::IsWindowCollapsed(); ImGui::Text("%s", "Persistent Memory Pool"); - renderMemoryPoolInformation(global::memoryManager.PersistentMemory); + renderMemoryPoolInformation(global::memoryManager->PersistentMemory); //ImGui::Text("%s", "Temporary Memory Pool"); //renderMemoryPoolInformation(global::memoryManager.TemporaryMemory); diff --git a/modules/imgui/src/guimissioncomponent.cpp b/modules/imgui/src/guimissioncomponent.cpp index 49a7c9e3b4..a91eb86dbc 100644 --- a/modules/imgui/src/guimissioncomponent.cpp +++ b/modules/imgui/src/guimissioncomponent.cpp @@ -42,7 +42,7 @@ namespace { std::string missionHashname = "##" + mission.name(); - const double currentTime = openspace::global::timeManager.time().j2000Seconds(); + const double currentTime = openspace::global::timeManager->time().j2000Seconds(); openspace::MissionPhase::Trace t = mission.phaseTrace(currentTime, 0); int treeOption = t.empty() ? 0 : ImGuiTreeNodeFlags_DefaultOpen; @@ -74,7 +74,7 @@ namespace { &v, s, e, - std::string(openspace::global::timeManager.time().UTC()).c_str() + std::string(openspace::global::timeManager->time().UTC()).c_str() ); ImGui::SameLine(); ImGui::Text("%s", std::string(endTime.UTC()).c_str()); @@ -98,7 +98,7 @@ GuiMissionComponent::GuiMissionComponent() {} void GuiMissionComponent::render() { - if (!global::missionManager.hasCurrentMission()) { + if (!global::missionManager->hasCurrentMission()) { return; } @@ -109,7 +109,7 @@ void GuiMissionComponent::render() { _isCollapsed = ImGui::IsWindowCollapsed(); - const Mission& currentMission = global::missionManager.currentMission(); + const Mission& currentMission = global::missionManager->currentMission(); renderMission(currentMission); ImGui::End(); diff --git a/modules/imgui/src/guiparallelcomponent.cpp b/modules/imgui/src/guiparallelcomponent.cpp index 60527364bc..b854f05697 100644 --- a/modules/imgui/src/guiparallelcomponent.cpp +++ b/modules/imgui/src/guiparallelcomponent.cpp @@ -50,7 +50,7 @@ void GuiParallelComponent::renderDisconnected() { const bool connect = ImGui::Button("Connect"); if (connect) { - global::parallelPeer.connect(); + global::parallelPeer->connect(); } } @@ -59,12 +59,12 @@ void GuiParallelComponent::renderConnecting() { const bool cancel = ImGui::Button("Cancel connection"); if (cancel) { - global::parallelPeer.disconnect(); + global::parallelPeer->disconnect(); } } void GuiParallelComponent::renderClientWithHost() { - ParallelPeer& parallel = global::parallelPeer; + ParallelPeer& parallel = *global::parallelPeer; std::string connectionInfo = "Session hosted by \"" + parallel.hostName() + "\"\n"; const size_t nConnections = parallel.nConnections(); @@ -85,9 +85,9 @@ void GuiParallelComponent::renderClientWithHost() { ImGui::Text("%s", connectionInfo.c_str()); renderClientCommon(); - const size_t nTimeKeyframes = global::timeManager.nKeyframes(); + const size_t nTimeKeyframes = global::timeManager->nKeyframes(); const size_t nCameraKeyframes = - global::navigationHandler.keyframeNavigator().nKeyframes(); + global::navigationHandler->keyframeNavigator().nKeyframes(); std::string timeKeyframeInfo = "TimeKeyframes : " + std::to_string(nTimeKeyframes); std::string cameraKeyframeInfo = "CameraKeyframes : " + @@ -108,7 +108,7 @@ void GuiParallelComponent::renderClientWithHost() { void GuiParallelComponent::renderClientWithoutHost() { std::string connectionInfo = "Connected to parallel session with no host\n"; - const size_t nConnections = global::parallelPeer.nConnections(); + const size_t nConnections = global::parallelPeer->nConnections(); if (nConnections > 2) { std::string c = std::to_string(nConnections - 1); @@ -130,17 +130,17 @@ void GuiParallelComponent::renderClientWithoutHost() { void GuiParallelComponent::renderClientCommon() { const bool requestHostship = ImGui::Button("Request hostship"); if (requestHostship) { - global::parallelPeer.requestHostship(); + global::parallelPeer->requestHostship(); } const bool disconnect = ImGui::Button("Disconnect"); if (disconnect) { - global::parallelPeer.disconnect(); + global::parallelPeer->disconnect(); } } void GuiParallelComponent::renderHost() { - const size_t nConnections = global::parallelPeer.nConnections(); + const size_t nConnections = global::parallelPeer->nConnections(); std::string connectionInfo; const size_t nClients = nConnections - 1; @@ -155,7 +155,7 @@ void GuiParallelComponent::renderHost() { const bool resignHostship = ImGui::Button("Resign hostship"); if (resignHostship) { - global::parallelPeer.resignHostship(); + global::parallelPeer->resignHostship(); } } @@ -167,7 +167,7 @@ void GuiParallelComponent::render() { _isEnabled = v; _isCollapsed = ImGui::IsWindowCollapsed(); - ParallelConnection::Status status = global::parallelPeer.status(); + ParallelConnection::Status status = global::parallelPeer->status(); switch (status) { case ParallelConnection::Status::Disconnected: @@ -187,7 +187,7 @@ void GuiParallelComponent::render() { break; } - GuiPropertyComponent::renderPropertyOwner(&global::parallelPeer); + GuiPropertyComponent::renderPropertyOwner(global::parallelPeer); ImGui::End(); } diff --git a/modules/imgui/src/guishortcutscomponent.cpp b/modules/imgui/src/guishortcutscomponent.cpp index 7379408e3b..17e0aaca94 100644 --- a/modules/imgui/src/guishortcutscomponent.cpp +++ b/modules/imgui/src/guishortcutscomponent.cpp @@ -52,13 +52,13 @@ void GuiShortcutsComponent::render() { // First the actual shortcuts CaptionText("Shortcuts"); const std::vector& shortcuts = - global::shortcutManager.shortcuts(); + global::shortcutManager->shortcuts(); for (size_t i = 0; i < shortcuts.size(); ++i) { const interaction::ShortcutManager::ShortcutInformation& info = shortcuts[i]; if (ImGui::Button(info.name.c_str())) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( info.script, scripting::ScriptEngine::RemoteScripting(info.synchronization) ); @@ -83,11 +83,11 @@ void GuiShortcutsComponent::render() { CaptionText("Keybindings"); using K = KeyWithModifier; using V = interaction::KeybindingManager::KeyInformation; - const std::multimap& binds = global::keybindingManager.keyBindings(); + const std::multimap& binds = global::keybindingManager->keyBindings(); for (const std::pair& p : binds) { if (ImGui::Button(ghoul::to_string(p.first).c_str())) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( p.second.command, scripting::ScriptEngine::RemoteScripting(p.second.synchronization) ); diff --git a/modules/imgui/src/guispacetimecomponent.cpp b/modules/imgui/src/guispacetimecomponent.cpp index 132d52f466..2508abef96 100644 --- a/modules/imgui/src/guispacetimecomponent.cpp +++ b/modules/imgui/src/guispacetimecomponent.cpp @@ -85,7 +85,7 @@ void GuiSpaceTimeComponent::render() { _isCollapsed = ImGui::IsWindowCollapsed(); std::vector nodes = - global::renderEngine.scene()->allSceneGraphNodes(); + global::renderEngine->scene()->allSceneGraphNodes(); std::sort( nodes.begin(), @@ -107,13 +107,13 @@ void GuiSpaceTimeComponent::render() { const bool pressed = ImGui::Button(n->guiName().c_str()); ImGui::SameLine(); if (pressed) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.setPropertyValue('" + std::string(AnchorProperty) + "', '" + n->identifier() + "');", scripting::ScriptEngine::RemoteScripting::Yes ); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.setPropertyValue('" + std::string(RetargetAnchorProperty) + "', nil);", scripting::ScriptEngine::RemoteScripting::Yes @@ -126,7 +126,7 @@ void GuiSpaceTimeComponent::render() { ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.f); const SceneGraphNode* currentFocus = - global::navigationHandler.orbitalNavigator().anchorNode(); + global::navigationHandler->orbitalNavigator().anchorNode(); std::string nodeNames; for (SceneGraphNode* n : nodes) { @@ -143,12 +143,12 @@ void GuiSpaceTimeComponent::render() { const bool hasChanged = ImGui::Combo("", ¤tPosition, nodeNames.c_str()); if (hasChanged) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.setPropertyValue('" + std::string(AnchorProperty) + "', '" + nodes[currentPosition]->identifier() + "');", scripting::ScriptEngine::RemoteScripting::Yes ); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.setPropertyValue('" + std::string(RetargetAnchorProperty) + "', nil);", scripting::ScriptEngine::RemoteScripting::Yes @@ -158,14 +158,14 @@ void GuiSpaceTimeComponent::render() { ImGui::SameLine(); const bool pressed = ImGui::Button("Refocus"); if (pressed) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.setPropertyValue('" + std::string(RetargetAnchorProperty) + "', nil);", scripting::ScriptEngine::RemoteScripting::Yes ); } - float interpolationTime = global::navigationHandler.interpolationTime(); + float interpolationTime = global::navigationHandler->interpolationTime(); const bool interpolationTimeChanged = ImGui::SliderFloat( "Interpolation Time", &interpolationTime, @@ -175,7 +175,7 @@ void GuiSpaceTimeComponent::render() { ); if (interpolationTimeChanged) { - global::navigationHandler.setInterpolationTime(interpolationTime); + global::navigationHandler->setInterpolationTime(interpolationTime); } ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20.f); @@ -190,14 +190,14 @@ void GuiSpaceTimeComponent::render() { ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.f); const std::vector& interestingTimes = - global::renderEngine.scene()->interestingTimes(); + global::renderEngine->scene()->interestingTimes(); if (!interestingTimes.empty()) { ImGui::Text("%s", "Interesting Times"); for (size_t i = 0; i < interestingTimes.size(); ++i) { const Scene::InterestingTime& t = interestingTimes[i]; if (ImGui::Button(t.name.c_str())) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.setTime(\"" + t.time + "\")", scripting::ScriptEngine::RemoteScripting::No ); @@ -213,7 +213,7 @@ void GuiSpaceTimeComponent::render() { ImGui::Text( "Current Date: %s", - std::string(global::timeManager.time().UTC()).c_str() + std::string(global::timeManager->time().UTC()).c_str() ); constexpr int BufferSize = 256; @@ -225,7 +225,7 @@ void GuiSpaceTimeComponent::render() { ImGuiInputTextFlags_EnterReturnsTrue ); if (dateChanged) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.setTime(\"" + std::string(Buffer) + "\")", scripting::ScriptEngine::RemoteScripting::No ); @@ -242,10 +242,10 @@ void GuiSpaceTimeComponent::render() { auto incrementTime = [shift = ImGui::GetIO().KeyShift](float days) { using namespace std::chrono; - const float duration = global::timeManager.defaultTimeInterpolationDuration(); + const float duration = global::timeManager->defaultTimeInterpolationDuration(); - const TimeKeyframeData predictedTime = global::timeManager.interpolate( - global::windowDelegate.applicationTime() + duration + const TimeKeyframeData predictedTime = global::timeManager->interpolate( + global::windowDelegate->applicationTime() + duration ); const double j2000 = predictedTime.time.j2000Seconds(); const long long seconds = duration_cast( @@ -258,13 +258,13 @@ void GuiSpaceTimeComponent::render() { if (shift) { // If any shift key is pressed we want to always jump to the time - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.setTime(" + std::to_string(newTime) + ")", scripting::ScriptEngine::RemoteScripting::No ); } else { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateTime(" + std::to_string(newTime) + ", " + std::to_string(duration) + ")", scripting::ScriptEngine::RemoteScripting::No @@ -304,7 +304,7 @@ void GuiSpaceTimeComponent::render() { // setTime doesn't like the T in it and wants a space instead nowTime[11] = ' '; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.setTime(\"" + nowTime + "\")", scripting::ScriptEngine::RemoteScripting::No ); @@ -339,7 +339,7 @@ void GuiSpaceTimeComponent::render() { ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20.f); // { - const float dt = static_cast(global::timeManager.targetDeltaTime()); + const float dt = static_cast(global::timeManager->targetDeltaTime()); if (_firstFrame) { const std::pair& dtInfo = simplifyTime(dt); _deltaTime = static_cast(dtInfo.first); @@ -383,7 +383,7 @@ void GuiSpaceTimeComponent::render() { // If the value changed, we want to change the delta time to the new value double newDt = convertTime(_deltaTime, _deltaTimeUnit, TimeUnit::Second); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateDeltaTime(" + std::to_string(newDt) + ")", scripting::ScriptEngine::RemoteScripting::No ); @@ -431,14 +431,14 @@ void GuiSpaceTimeComponent::render() { TimeUnit::Second ); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.setDeltaTime(" + std::to_string(newDeltaTime) + ")", scripting::ScriptEngine::RemoteScripting::No ); } if (!ImGui::IsItemActive() && !ImGui::IsItemClicked()) { if (_slidingDelta != 0.f) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.setDeltaTime(" + std::to_string(_oldDeltaTime) + ")", scripting::ScriptEngine::RemoteScripting::No ); @@ -459,12 +459,13 @@ void GuiSpaceTimeComponent::render() { if (accelerationDeltaChanged || ImGui::IsItemActive() || ImGui::IsItemClicked()) { // We want the value to change by _accelerationDelta every 100 real world ms const double newDeltaTime = convertTime( - _deltaTime + _accelerationDelta * global::windowDelegate.deltaTime() * 10, + _deltaTime + + _accelerationDelta * global::windowDelegate->deltaTime() * 10, static_cast(_deltaTimeUnit), TimeUnit::Second ); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.setDeltaTime(" + std::to_string(newDeltaTime) + ")", scripting::ScriptEngine::RemoteScripting::No ); @@ -476,13 +477,13 @@ void GuiSpaceTimeComponent::render() { _deltaTime -= _slidingDelta; } - const bool isPaused = global::timeManager.isPaused(); + const bool isPaused = global::timeManager->isPaused(); const bool pauseChanged = ImGui::Button( isPaused ? "Resume" : "Pause", { ImGui::GetWindowWidth() / 2 - 7.5f, 0.f } ); if (pauseChanged) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateTogglePause()", scripting::ScriptEngine::RemoteScripting::No ); @@ -493,7 +494,7 @@ void GuiSpaceTimeComponent::render() { { ImGui::GetWindowWidth() / 2 - 7.5f, 0.f } ); if (invert) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateDeltaTime(-1 * openspace.time.deltaTime());", scripting::ScriptEngine::RemoteScripting::No ); @@ -501,7 +502,7 @@ void GuiSpaceTimeComponent::render() { const bool minusDs = ImGui::Button("-1d/s"); if (minusDs) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateDeltaTime(" + std::to_string(-24 * 60 * 60) + ")", scripting::ScriptEngine::RemoteScripting::No ); @@ -510,7 +511,7 @@ void GuiSpaceTimeComponent::render() { const bool minusHs = ImGui::Button("-1h/s"); if (minusHs) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateDeltaTime(" + std::to_string(-60 * 60) + ")", scripting::ScriptEngine::RemoteScripting::No ); @@ -519,7 +520,7 @@ void GuiSpaceTimeComponent::render() { const bool minusMs = ImGui::Button("-1min/s"); if (minusMs) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateDeltaTime(" + std::to_string(-60) + ")", scripting::ScriptEngine::RemoteScripting::No ); @@ -528,7 +529,7 @@ void GuiSpaceTimeComponent::render() { const bool minusSs = ImGui::Button("-1s/s"); if (minusSs) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateDeltaTime(" + std::to_string(-1) + ")", scripting::ScriptEngine::RemoteScripting::No ); @@ -537,7 +538,7 @@ void GuiSpaceTimeComponent::render() { const bool zero = ImGui::Button("0"); if (zero) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateDeltaTime(" + std::to_string(0) + ")", scripting::ScriptEngine::RemoteScripting::No ); @@ -547,7 +548,7 @@ void GuiSpaceTimeComponent::render() { const bool plusSs = ImGui::Button("+1s/s"); if (plusSs) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateDeltaTime(" + std::to_string(1) + ")", scripting::ScriptEngine::RemoteScripting::No ); @@ -556,7 +557,7 @@ void GuiSpaceTimeComponent::render() { const bool plusMs = ImGui::Button("1min/s"); if (plusMs) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateDeltaTime(" + std::to_string(60) + ")", scripting::ScriptEngine::RemoteScripting::No ); @@ -565,7 +566,7 @@ void GuiSpaceTimeComponent::render() { const bool plusHs = ImGui::Button("1h/s"); if (plusHs) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateDeltaTime(" + std::to_string(60 * 60) + ")", scripting::ScriptEngine::RemoteScripting::No ); @@ -574,7 +575,7 @@ void GuiSpaceTimeComponent::render() { const bool plusDs = ImGui::Button("1d/s"); if (plusDs) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.interpolateDeltaTime(" + std::to_string(24 * 60 * 60) + ")", scripting::ScriptEngine::RemoteScripting::No ); diff --git a/modules/imgui/src/renderproperties.cpp b/modules/imgui/src/renderproperties.cpp index 6621461ad7..4d20ef70f0 100644 --- a/modules/imgui/src/renderproperties.cpp +++ b/modules/imgui/src/renderproperties.cpp @@ -69,14 +69,14 @@ void renderTooltip(Property* prop, double delay) { } void executeScriptSingle(const std::string& id, const std::string& value) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.setPropertyValueSingle('" + id + "', " + value + ");", scripting::ScriptEngine::RemoteScripting::Yes ); } void executeScriptGroup(const std::string& id, const std::string& value) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.setPropertyValue('" + id + "', " + value + ");", scripting::ScriptEngine::RemoteScripting::Yes ); diff --git a/modules/iswa/rendering/dataplane.cpp b/modules/iswa/rendering/dataplane.cpp index a4dcc8ce83..5128c9606b 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -39,7 +39,7 @@ void DataPlane::initializeGL() { IswaCygnet::initialize(); if (!_shader) { - _shader = global::renderEngine.buildRenderProgram( + _shader = global::renderEngine->buildRenderProgram( "DataPlaneProgram", absPath("${MODULE_ISWA}/shaders/dataplane_vs.glsl"), absPath("${MODULE_ISWA}/shaders/dataplane_fs.glsl") diff --git a/modules/iswa/rendering/datasphere.cpp b/modules/iswa/rendering/datasphere.cpp index 318b9d8a19..208e3af6ef 100644 --- a/modules/iswa/rendering/datasphere.cpp +++ b/modules/iswa/rendering/datasphere.cpp @@ -47,7 +47,7 @@ void DataSphere::initializeGL() { IswaCygnet::initializeGL(); if (!_shader) { - _shader = global::renderEngine.buildRenderProgram( + _shader = global::renderEngine->buildRenderProgram( "DataSphereProgram", absPath("${MODULE_ISWA}/shaders/datasphere_vs.glsl"), absPath("${MODULE_ISWA}/shaders/datasphere_fs.glsl") diff --git a/modules/iswa/rendering/iswacygnet.cpp b/modules/iswa/rendering/iswacygnet.cpp index 2482037464..651ff8561b 100644 --- a/modules/iswa/rendering/iswacygnet.cpp +++ b/modules/iswa/rendering/iswacygnet.cpp @@ -114,7 +114,7 @@ void IswaCygnet::initializeGL() { else { _delete.onChange([this]() { deinitialize(); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.removeSceneGraphNode('" + identifier() + "')", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -123,7 +123,7 @@ void IswaCygnet::initializeGL() { initializeTime(); createGeometry(); - downloadTextureResource(global::timeManager.time().j2000Seconds()); + downloadTextureResource(global::timeManager->time().j2000Seconds()); } void IswaCygnet::deinitializeGL() { @@ -135,7 +135,7 @@ void IswaCygnet::deinitializeGL() { destroyGeometry(); if (_shader) { - global::renderEngine.removeRenderProgram(_shader.get()); + global::renderEngine->removeRenderProgram(_shader.get()); _shader = nullptr; } } @@ -193,7 +193,7 @@ void IswaCygnet::update(const UpdateData&) { // the texture resource is downloaded ahead of time, so we need to // now if we are going backwards or forwards - _openSpaceTime = global::timeManager.time().j2000Seconds(); + _openSpaceTime = global::timeManager->time().j2000Seconds(); _realTime = std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch() ); @@ -218,7 +218,7 @@ void IswaCygnet::update(const UpdateData&) { updateTexture(); _textureDirty = false; - double clockwiseSign = (global::timeManager.deltaTime() > 0) ? 1.0 : -1.0; + double clockwiseSign = (global::timeManager->deltaTime() > 0) ? 1.0 : -1.0; downloadTextureResource(_openSpaceTime + clockwiseSign * _data.updateTime); _lastUpdateRealTime = _realTime; _lastUpdateOpenSpaceTime = _openSpaceTime; @@ -240,7 +240,7 @@ void IswaCygnet::registerProperties() {} void IswaCygnet::unregisterProperties() {} void IswaCygnet::initializeTime() { - _openSpaceTime = global::timeManager.time().j2000Seconds(); + _openSpaceTime = global::timeManager->time().j2000Seconds(); _lastUpdateOpenSpaceTime = 0.0; _realTime = std::chrono::duration_cast( @@ -277,7 +277,7 @@ void IswaCygnet::initializeGroup() { groupEvent.subscribe(identifier(), "clearGroup", [&](ghoul::Dictionary) { LDEBUG(identifier() + " Event clearGroup"); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.removeSceneGraphNode('" + identifier() + "')", scripting::ScriptEngine::RemoteScripting::Yes ); diff --git a/modules/iswa/rendering/iswakameleongroup.cpp b/modules/iswa/rendering/iswakameleongroup.cpp index df227ff0b5..8d6928ba93 100644 --- a/modules/iswa/rendering/iswakameleongroup.cpp +++ b/modules/iswa/rendering/iswakameleongroup.cpp @@ -149,7 +149,7 @@ void IswaKameleonGroup::updateFieldlineSeeds() { if (it == options.end() && std::get<2>(seedPath.second)) { LDEBUG("Removed fieldlines: " + std::get<0>(seedPath.second)); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.removeSceneGraphNode('" + std::get<0>(seedPath.second) + "')", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -176,7 +176,7 @@ void IswaKameleonGroup::clearFieldlines() { if (std::get<2>(seedPath.second)) { LDEBUG("Removed fieldlines: " + std::get<0>(seedPath.second)); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.removeSceneGraphNode('" + std::get<0>(seedPath.second) + "')", scripting::ScriptEngine::RemoteScripting::Yes ); diff --git a/modules/iswa/rendering/kameleonplane.cpp b/modules/iswa/rendering/kameleonplane.cpp index bfc889e835..93a42400d8 100644 --- a/modules/iswa/rendering/kameleonplane.cpp +++ b/modules/iswa/rendering/kameleonplane.cpp @@ -112,7 +112,7 @@ void KameleonPlane::deinitializeGL() { void KameleonPlane::initializeGL() { if (!_shader) { - _shader = global::renderEngine.buildRenderProgram( + _shader = global::renderEngine->buildRenderProgram( "DataPlaneProgram", absPath("${MODULE_ISWA}/shaders/dataplane_vs.glsl"), absPath("${MODULE_ISWA}/shaders/dataplane_fs.glsl") @@ -274,7 +274,7 @@ void KameleonPlane::updateFieldlineSeeds() { seedPath.first ); if (it == selectedOptions.end() && std::get<2>(seedPath.second)) { - SceneGraphNode* n = global::renderEngine.scene()->sceneGraphNode( + SceneGraphNode* n = global::renderEngine->scene()->sceneGraphNode( std::get<0>(seedPath.second) ); if (!n) { @@ -282,7 +282,7 @@ void KameleonPlane::updateFieldlineSeeds() { } LDEBUG("Removed fieldlines: " + std::get<0>(seedPath.second)); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.removeSceneGraphNode('" + std::get<0>(seedPath.second) + "')", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -290,7 +290,7 @@ void KameleonPlane::updateFieldlineSeeds() { // if this option was turned on } else if (it != selectedOptions.end() && !std::get<2>(seedPath.second)) { - SceneGraphNode* n = global::renderEngine.scene()->sceneGraphNode( + SceneGraphNode* n = global::renderEngine->scene()->sceneGraphNode( std::get<0>(seedPath.second) ); if (n) { diff --git a/modules/iswa/rendering/screenspacecygnet.cpp b/modules/iswa/rendering/screenspacecygnet.cpp index 4148ad3fc7..fc378db93b 100644 --- a/modules/iswa/rendering/screenspacecygnet.cpp +++ b/modules/iswa/rendering/screenspacecygnet.cpp @@ -40,10 +40,10 @@ ScreenSpaceCygnet::ScreenSpaceCygnet(const ghoul::Dictionary& dictionary) _downloadImage = true; _texturePath = IswaManager::ref().iswaUrl( _cygnetId, - global::timeManager.time().j2000Seconds() + global::timeManager->time().j2000Seconds() ); - _openSpaceTime = global::timeManager.time().j2000Seconds(); + _openSpaceTime = global::timeManager->time().j2000Seconds(); _lastUpdateOpenSpaceTime = _openSpaceTime; _realTime = std::chrono::duration_cast( @@ -53,7 +53,7 @@ ScreenSpaceCygnet::ScreenSpaceCygnet(const ghoul::Dictionary& dictionary) _minRealTimeUpdateInterval = 100; _delete.onChange([this]() { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.iswa.removeScreenSpaceCygnet("+std::to_string(_cygnetId)+");", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -61,7 +61,7 @@ ScreenSpaceCygnet::ScreenSpaceCygnet(const ghoul::Dictionary& dictionary) } void ScreenSpaceCygnet::update() { - _openSpaceTime = global::timeManager.time().j2000Seconds(); + _openSpaceTime = global::timeManager->time().j2000Seconds(); _realTime = std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch() ); @@ -72,7 +72,7 @@ void ScreenSpaceCygnet::update() { if (timeToUpdate) { _texturePath = IswaManager::ref().iswaUrl( _cygnetId, - global::timeManager.time().j2000Seconds() + global::timeManager->time().j2000Seconds() ); _lastUpdateRealTime = _realTime; _lastUpdateOpenSpaceTime = _openSpaceTime; diff --git a/modules/iswa/rendering/textureplane.cpp b/modules/iswa/rendering/textureplane.cpp index 7dfc0bf0c4..57d1ef7cf9 100644 --- a/modules/iswa/rendering/textureplane.cpp +++ b/modules/iswa/rendering/textureplane.cpp @@ -39,7 +39,7 @@ TexturePlane::TexturePlane(const ghoul::Dictionary& dictionary) void TexturePlane::initializeGL() { if (!_shader) { - _shader = global::renderEngine.buildRenderProgram( + _shader = global::renderEngine->buildRenderProgram( "PlaneProgram", absPath("${MODULE_ISWA}/shaders/textureplane_vs.glsl"), absPath("${MODULE_ISWA}/shaders/textureplane_fs.glsl") diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index 7d0eb666b9..2d5cec6064 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -84,7 +84,7 @@ namespace { void createScreenSpace(int id) { std::string idStr = std::to_string(id); - openspace::global::scriptEngine.queueScript( + openspace::global::scriptEngine->queueScript( "openspace.iswa.addScreenSpaceCygnet({CygnetId =" + idStr + "});", openspace::scripting::ScriptEngine::RemoteScripting::Yes ); @@ -190,7 +190,7 @@ void IswaManager::addIswaCygnet(int id, const std::string& type, std::string gro }; // Download metadata - global::downloadManager.fetchFile( + global::downloadManager->fetchFile( _baseUrl + std::to_string(-id), metadataCallback, [id](const std::string& err) { @@ -221,7 +221,7 @@ void IswaManager::addKameleonCdf(std::string groupName, int pos) { std::future IswaManager::fetchImageCygnet(int id, double timestamp) { - return global::downloadManager.fetchFile( + return global::downloadManager->fetchFile( iswaUrl(id, timestamp, "image"), [id](const DownloadManager::MemoryFile&) { LDEBUG( @@ -241,7 +241,7 @@ std::future IswaManager::fetchImageCygnet(int id, std::future IswaManager::fetchDataCygnet(int id, double timestamp) { - return global::downloadManager.fetchFile( + return global::downloadManager->fetchFile( iswaUrl(id, timestamp, "data"), [id](const DownloadManager::MemoryFile&) { LDEBUG( @@ -340,7 +340,7 @@ std::shared_ptr IswaManager::downloadMetadata(int id) { std::shared_ptr metaFuture = std::make_shared(); metaFuture->id = id; - global::downloadManager.fetchFile( + global::downloadManager->fetchFile( _baseUrl + std::to_string(-id), [&metaFuture](const DownloadManager::MemoryFile& file) { metaFuture->json = std::string(file.buffer, file.buffer + file.size); @@ -542,7 +542,7 @@ void IswaManager::createPlane(MetadataFuture& data) { data.name = name; - if (global::renderEngine.scene()->sceneGraphNode(name)) { + if (global::renderEngine->scene()->sceneGraphNode(name)) { LERROR("A node with name \"" + name + "\" already exist"); return; } @@ -550,7 +550,7 @@ void IswaManager::createPlane(MetadataFuture& data) { std::string luaTable = jsonPlaneToLuaTable(data); if (!luaTable.empty()) { std::string script = "openspace.addSceneGraphNode(" + luaTable + ");"; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( script, scripting::ScriptEngine::RemoteScripting::Yes ); @@ -576,14 +576,14 @@ void IswaManager::createSphere(MetadataFuture& data) { data.name = name; - if (global::renderEngine.scene()->sceneGraphNode(name)) { + if (global::renderEngine->scene()->sceneGraphNode(name)) { LERROR("A node with name \"" + name +"\" already exist"); return; } std::string luaTable = jsonSphereToLuaTable(data); if (luaTable != "") { std::string script = "openspace.addSceneGraphNode(" + luaTable + ");"; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( script, scripting::ScriptEngine::RemoteScripting::Yes ); @@ -610,7 +610,7 @@ void IswaManager::createKameleonPlane(CdfInfo info, std::string cut) { info.name = info.name + "-" + cut; - if (global::renderEngine.scene()->sceneGraphNode(info.name)) { + if (global::renderEngine->scene()->sceneGraphNode(info.name)) { LERROR("A node with name \"" + info.name +"\" already exist"); return; } @@ -618,7 +618,7 @@ void IswaManager::createKameleonPlane(CdfInfo info, std::string cut) { std::string luaTable = parseKWToLuaTable(info, cut); if (!luaTable.empty()) { std::string script = "openspace.addSceneGraphNode(" + luaTable + ");"; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( script, scripting::ScriptEngine::RemoteScripting::Yes ); @@ -658,14 +658,14 @@ void IswaManager::createFieldline(std::string name, std::string cdfPath, "}"; if (!luaTable.empty()) { std::string script = "openspace.addSceneGraphNode(" + luaTable + ");"; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( script, scripting::ScriptEngine::RemoteScripting::Yes ); } } else { - LWARNING( cdfPath + " is not a cdf file or can't be found."); + LWARNING(cdfPath + " is not a cdf file or can't be found"); } } diff --git a/modules/iswa/util/iswamanager_lua.inl b/modules/iswa/util/iswamanager_lua.inl index b2f609ad3c..b5e8dbbc70 100644 --- a/modules/iswa/util/iswamanager_lua.inl +++ b/modules/iswa/util/iswamanager_lua.inl @@ -85,7 +85,7 @@ int iswa_addScreenSpaceCygnet(lua_State* L) { int updateInterval = info->updateInterval; info->selected = true; - if (global::renderEngine.screenSpaceRenderable(name)) { + if (global::renderEngine->screenSpaceRenderable(name)) { LERROR("A cygnet with the name \"" + name +"\" already exist"); return 0; } @@ -97,7 +97,7 @@ int iswa_addScreenSpaceCygnet(lua_State* L) { std::unique_ptr s( ScreenSpaceRenderable::createFromDictionary(d) ); - global::renderEngine.addScreenSpaceRenderable(std::move(s)); + global::renderEngine->addScreenSpaceRenderable(std::move(s)); } return 0; } @@ -127,7 +127,7 @@ int iswa_addScreenSpaceCygnet(lua_State* L) { int iswa_removeCygnet(lua_State* L) { std::string name = luaL_checkstring(L, -1); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.removeSceneGraphNode('" + name + "')", scripting::ScriptEngine::RemoteScripting::Yes ); @@ -153,7 +153,7 @@ int iswa_removeScrenSpaceCygnet(lua_State* L) { "openspace.unregisterScreenSpaceRenderable('" + cygnetInformation[id]->name + "');"; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( script, scripting::ScriptEngine::RemoteScripting::Yes ); diff --git a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp index 7daeed8749..76af40a5d4 100644 --- a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp +++ b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp @@ -264,14 +264,14 @@ void RenderableKameleonVolume::initializeGL() { _raycaster->initialize(); - global::raycasterManager.attachRaycaster(*_raycaster.get()); + global::raycasterManager->attachRaycaster(*_raycaster.get()); auto onChange = [&](bool enabled) { if (enabled) { - global::raycasterManager.attachRaycaster(*_raycaster.get()); + global::raycasterManager->attachRaycaster(*_raycaster.get()); } else { - global::raycasterManager.detachRaycaster(*_raycaster.get()); + global::raycasterManager->detachRaycaster(*_raycaster.get()); } }; @@ -438,7 +438,7 @@ void RenderableKameleonVolume::storeRaw(const std::string& path) { void RenderableKameleonVolume::deinitializeGL() { if (_raycaster) { - global::raycasterManager.detachRaycaster(*_raycaster.get()); + global::raycasterManager->detachRaycaster(*_raycaster.get()); _raycaster = nullptr; } } diff --git a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp index 02cfcaaf74..b35de6e4ee 100644 --- a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp +++ b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp @@ -428,14 +428,14 @@ void RenderableMultiresVolume::initializeGL() { ); _raycaster->initialize(); - global::raycasterManager.attachRaycaster(*_raycaster); + global::raycasterManager->attachRaycaster(*_raycaster); auto onChange = [&](bool enabled) { if (enabled) { - global::raycasterManager.attachRaycaster(*_raycaster); + global::raycasterManager->attachRaycaster(*_raycaster); } else { - global::raycasterManager.detachRaycaster(*_raycaster); + global::raycasterManager->detachRaycaster(*_raycaster); } }; diff --git a/modules/server/include/topics/topic.h b/modules/server/include/topics/topic.h index 1ce3d11004..64f3387a89 100644 --- a/modules/server/include/topics/topic.h +++ b/modules/server/include/topics/topic.h @@ -44,7 +44,7 @@ public: virtual bool isDone() const = 0; protected: - size_t _topicId; + size_t _topicId = 0; Connection* _connection; }; diff --git a/modules/server/servermodule.cpp b/modules/server/servermodule.cpp index 6d527b60b4..84910594da 100644 --- a/modules/server/servermodule.cpp +++ b/modules/server/servermodule.cpp @@ -100,7 +100,7 @@ void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) { ServerInterface::createFromDictionary(interfaceDictionary); - if (global::windowDelegate.isMaster()) { + if (global::windowDelegate->isMaster()) { serverInterface->initialize(); } @@ -113,7 +113,7 @@ void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) { } void ServerModule::preSync() { - if (!global::windowDelegate.isMaster()) { + if (!global::windowDelegate->isMaster()) { return; } @@ -185,7 +185,7 @@ void ServerModule::disconnectAll() { ZoneScoped for (std::unique_ptr& serverInterface : _interfaces) { - if (global::windowDelegate.isMaster()) { + if (global::windowDelegate->isMaster()) { serverInterface->deinitialize(); } } diff --git a/modules/server/src/topics/documentationtopic.cpp b/modules/server/src/topics/documentationtopic.cpp index c4fbfc3d29..d7dfb7c7c9 100644 --- a/modules/server/src/topics/documentationtopic.cpp +++ b/modules/server/src/topics/documentationtopic.cpp @@ -57,16 +57,16 @@ void DocumentationTopic::handleJson(const nlohmann::json& json) { // Do not parse generated json. Instead implement ability to get // ghoul::Dictionary objects from ScriptEngine, FactoryManager, and KeybindingManager. if (requestedType == TypeLua) { - response = json::parse(global::scriptEngine.generateJson()); + response = json::parse(global::scriptEngine->generateJson()); } else if (requestedType == TypeFactories) { response = json::parse(FactoryManager::ref().generateJson()); } else if (requestedType == TypeKeyboard) { - response = json::parse(global::keybindingManager.generateJson()); + response = json::parse(global::keybindingManager->generateJson()); } else if (requestedType == TypeAsset) { - response = json::parse(global::keybindingManager.generateJson()); + response = json::parse(global::keybindingManager->generateJson()); } else if (requestedType == TypeMeta) { std::string docs = SceneLicenseWriter().generateJson(); diff --git a/modules/server/src/topics/flightcontrollertopic.cpp b/modules/server/src/topics/flightcontrollertopic.cpp index 372c5c43ff..ed95e9df7b 100644 --- a/modules/server/src/topics/flightcontrollertopic.cpp +++ b/modules/server/src/topics/flightcontrollertopic.cpp @@ -159,20 +159,20 @@ namespace openspace { FlightControllerTopic::FlightControllerTopic() { for (auto it = AxisIndexMap.begin(); it != AxisIndexMap.end(); ++it) { - global::navigationHandler.setWebsocketAxisMapping( + global::navigationHandler->setWebsocketAxisMapping( int(std::distance(AxisIndexMap.begin(), it)), it->second ); } // Add WebsocketInputState to global states - global::websocketInputStates[_topicId] = &_inputState; + (*global::websocketInputStates)[_topicId] = &_inputState; } FlightControllerTopic::~FlightControllerTopic() { // Reset global websocketInputStates - global::websocketInputStates.erase(_topicId); - global::websocketInputStates = interaction::WebsocketInputStates(); + global::websocketInputStates->erase(_topicId); + *global::websocketInputStates = interaction::WebsocketInputStates(); } bool FlightControllerTopic::isDone() const { @@ -234,7 +234,7 @@ void FlightControllerTopic::connect() { void FlightControllerTopic::setFocusNodes() { // Get all scene nodes std::vector nodes = - global::renderEngine.scene()->allSceneGraphNodes(); + global::renderEngine->scene()->allSceneGraphNodes(); // Remove all nodes with no renderable nodes.erase( @@ -271,7 +271,7 @@ void FlightControllerTopic::setFocusNodes() { void FlightControllerTopic::setInterestingTimes() { std::vector times = - global::renderEngine.scene()->interestingTimes(); + global::renderEngine->scene()->interestingTimes(); std::sort( times.begin(), @@ -323,30 +323,30 @@ void FlightControllerTopic::changeFocus(const nlohmann::json& json) const { const bool retargetAnchor = json[RetargetAnchorKey]; const bool retargetAim = json[RetargetAimKey]; - Scene* scene = global::renderEngine.scene(); + Scene* scene = global::renderEngine->scene(); const SceneGraphNode* focusNode = scene->sceneGraphNode(focus); const SceneGraphNode* aimNode = scene->sceneGraphNode(aim); const SceneGraphNode* anchorNode = scene->sceneGraphNode(anchor); if (focusNode) { - global::navigationHandler.orbitalNavigator().setFocusNode( + global::navigationHandler->orbitalNavigator().setFocusNode( focusNode, resetVelocities ); } else { if (aimNode) { - global::navigationHandler.orbitalNavigator().setAimNode(aim); + global::navigationHandler->orbitalNavigator().setAimNode(aim); } if (anchorNode) { - global::navigationHandler.orbitalNavigator().setAnchorNode(anchor); + global::navigationHandler->orbitalNavigator().setAnchorNode(anchor); } } if (retargetAnchor) { - global::navigationHandler.orbitalNavigator().startRetargetAnchor(); + global::navigationHandler->orbitalNavigator().startRetargetAnchor(); } if (retargetAim) { - global::navigationHandler.orbitalNavigator().startRetargetAim(); + global::navigationHandler->orbitalNavigator().startRetargetAim(); } } @@ -362,7 +362,7 @@ void FlightControllerTopic::setRenderableEnabled(const nlohmann::json& json) con const std::string name = json[RenderableKey][SceneNodeName]; const bool enabled = json[RenderableKey][SceneNodeEnabled]; - const SceneGraphNode* node = global::renderEngine.scene()->sceneGraphNode(name); + const SceneGraphNode* node = global::renderEngine->scene()->sceneGraphNode(name); if (node && node->renderable() != nullptr) { node->renderable()->property(RenderableEnabled)->set(enabled); } @@ -370,8 +370,8 @@ void FlightControllerTopic::setRenderableEnabled(const nlohmann::json& json) con void FlightControllerTopic::disconnect() { // Reset global websocketInputStates - global::websocketInputStates.erase(_topicId); - global::websocketInputStates = interaction::WebsocketInputStates(); + global::websocketInputStates->erase(_topicId); + *global::websocketInputStates = interaction::WebsocketInputStates(); // Update FlightController nlohmann::json j; @@ -388,7 +388,7 @@ void FlightControllerTopic::setFriction(bool all) const { void FlightControllerTopic::setFriction(bool roll, bool rotation, bool zoom) const { const interaction::OrbitalNavigator& navigator = - global::navigationHandler.orbitalNavigator(); + global::navigationHandler->orbitalNavigator(); navigator.property(RollFriction)->set(roll); navigator.property(RotationalFriction)->set(rotation); @@ -476,7 +476,7 @@ void FlightControllerTopic::processInputState(const nlohmann::json& json) { void FlightControllerTopic::processLua(const nlohmann::json &json) { const std::string script = json[LuaScript]; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( script, openspace::scripting::ScriptEngine::RemoteScripting::Yes ); diff --git a/modules/server/src/topics/getpropertytopic.cpp b/modules/server/src/topics/getpropertytopic.cpp index d2669cc143..4c5cab7aec 100644 --- a/modules/server/src/topics/getpropertytopic.cpp +++ b/modules/server/src/topics/getpropertytopic.cpp @@ -64,7 +64,7 @@ void GetPropertyTopic::handleJson(const nlohmann::json& json) { } else if (requestedKey == AllScreenSpaceRenderablesValue) { response = wrappedPayload({ - { "value", global::renderEngine.screenSpaceRenderables() } + { "value", global::renderEngine->screenSpaceRenderables() } }); } else if (requestedKey == RootPropertyOwner) { diff --git a/modules/server/src/topics/luascripttopic.cpp b/modules/server/src/topics/luascripttopic.cpp index e340ccbbea..b059f15a51 100644 --- a/modules/server/src/topics/luascripttopic.cpp +++ b/modules/server/src/topics/luascripttopic.cpp @@ -190,7 +190,7 @@ void LuaScriptTopic::runScript(const std::string& script, bool shouldReturn) { _waitingForReturnValue = false; } - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( std::move(script), scripting::ScriptEngine::RemoteScripting::No, callback diff --git a/modules/server/src/topics/sessionrecordingtopic.cpp b/modules/server/src/topics/sessionrecordingtopic.cpp index eeb6e32b79..e16cda6d3f 100644 --- a/modules/server/src/topics/sessionrecordingtopic.cpp +++ b/modules/server/src/topics/sessionrecordingtopic.cpp @@ -51,7 +51,7 @@ SessionRecordingTopic::SessionRecordingTopic() { SessionRecordingTopic::~SessionRecordingTopic() { if (_stateCallbackHandle != UnsetOnChangeHandle) { - global::sessionRecording.removeStateChangeCallback(_stateCallbackHandle); + global::sessionRecording->removeStateChangeCallback(_stateCallbackHandle); } } @@ -98,10 +98,10 @@ void SessionRecordingTopic::handleJson(const nlohmann::json& json) { sendJsonData(); if (event == SubscribeEvent && _sendState) { - _stateCallbackHandle = global::sessionRecording.addStateChangeCallback( + _stateCallbackHandle = global::sessionRecording->addStateChangeCallback( [this]() { interaction::SessionRecording::SessionState currentState = - global::sessionRecording.state(); + global::sessionRecording->state(); if (currentState != _lastState) { sendJsonData(); _lastState = currentState; @@ -115,7 +115,7 @@ void SessionRecordingTopic::sendJsonData() { json stateJson; using SessionRecording = openspace::interaction::SessionRecording; if (_sendState) { - SessionRecording::SessionState state = global::sessionRecording.state(); + SessionRecording::SessionState state = global::sessionRecording->state(); std::string stateString; switch (state) { case SessionRecording::SessionState::Recording: @@ -131,7 +131,7 @@ void SessionRecordingTopic::sendJsonData() { stateJson[StateKey] = stateString; }; if (_sendFiles) { - stateJson[FilesKey] = global::sessionRecording.playbackList(); + stateJson[FilesKey] = global::sessionRecording->playbackList(); } if (!stateJson.empty()) { _connection->sendJson(wrappedPayload(stateJson)); diff --git a/modules/server/src/topics/setpropertytopic.cpp b/modules/server/src/topics/setpropertytopic.cpp index 76b05f1c37..a3cb994ab4 100644 --- a/modules/server/src/topics/setpropertytopic.cpp +++ b/modules/server/src/topics/setpropertytopic.cpp @@ -110,13 +110,13 @@ void SetPropertyTopic::handleJson(const nlohmann::json& json) { if (propertyKey == SpecialKeyTime) { Time newTime; newTime.setTime(json.at(ValueKey).get()); - global::timeManager.setTimeNextFrame(newTime); + global::timeManager->setTimeNextFrame(newTime); } else { nlohmann::json value = json.at(ValueKey); std::string literal = luaLiteralFromJson(value); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( fmt::format( "openspace.setPropertyValueSingle(\"{}\", {})", propertyKey, literal ), diff --git a/modules/server/src/topics/shortcuttopic.cpp b/modules/server/src/topics/shortcuttopic.cpp index 34376e0c69..b215054583 100644 --- a/modules/server/src/topics/shortcuttopic.cpp +++ b/modules/server/src/topics/shortcuttopic.cpp @@ -47,7 +47,7 @@ std::vector ShortcutTopic::shortcutsJson() const { using ShortcutInformation = interaction::ShortcutManager::ShortcutInformation; const std::vector& shortcuts = - global::shortcutManager.shortcuts(); + global::shortcutManager->shortcuts(); std::vector json; for (const ShortcutInformation& shortcut : shortcuts) { @@ -64,7 +64,7 @@ std::vector ShortcutTopic::shortcutsJson() const { using KeyInformation = interaction::KeybindingManager::KeyInformation; const std::multimap& keyBindings = - global::keybindingManager.keyBindings(); + global::keybindingManager->keyBindings(); for (const std::pair& keyBinding : keyBindings) { diff --git a/modules/server/src/topics/timetopic.cpp b/modules/server/src/topics/timetopic.cpp index 507f9b6904..57d61adb9b 100644 --- a/modules/server/src/topics/timetopic.cpp +++ b/modules/server/src/topics/timetopic.cpp @@ -48,13 +48,15 @@ TimeTopic::TimeTopic() TimeTopic::~TimeTopic() { if (_timeCallbackHandle != UnsetOnChangeHandle) { - global::timeManager.removeTimeChangeCallback(_timeCallbackHandle); + global::timeManager->removeTimeChangeCallback(_timeCallbackHandle); } if (_deltaTimeCallbackHandle != UnsetOnChangeHandle) { - global::timeManager.removeDeltaTimeChangeCallback(_deltaTimeCallbackHandle); + global::timeManager->removeDeltaTimeChangeCallback(_deltaTimeCallbackHandle); } if (_deltaTimeStepsCallbackHandle != UnsetOnChangeHandle) { - global::timeManager.removeDeltaTimeStepsChangeCallback(_deltaTimeStepsCallbackHandle); + global::timeManager->removeDeltaTimeStepsChangeCallback( + _deltaTimeStepsCallbackHandle + ); } } @@ -77,20 +79,20 @@ void TimeTopic::handleJson(const nlohmann::json& json) { return; } - _timeCallbackHandle = global::timeManager.addTimeChangeCallback([this]() { + _timeCallbackHandle = global::timeManager->addTimeChangeCallback([this]() { std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); if (now - _lastUpdateTime > TimeUpdateInterval) { sendCurrentTime(); } }); - _deltaTimeCallbackHandle = global::timeManager.addDeltaTimeChangeCallback([this]() { + _deltaTimeCallbackHandle = global::timeManager->addDeltaTimeChangeCallback([this]() { // Throttle by last update, // but force update if pause state or target delta changes. std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); - const double targetDeltaTime = global::timeManager.targetDeltaTime(); - const bool isPaused = global::timeManager.isPaused(); + const double targetDeltaTime = global::timeManager->targetDeltaTime(); + const bool isPaused = global::timeManager->isPaused(); const bool forceUpdate = isPaused != _lastPauseState || targetDeltaTime != _lastTargetDeltaTime; @@ -99,9 +101,9 @@ void TimeTopic::handleJson(const nlohmann::json& json) { } }); - _deltaTimeStepsCallbackHandle = global::timeManager.addDeltaTimeStepsChangeCallback( + _deltaTimeStepsCallbackHandle = global::timeManager->addDeltaTimeStepsChangeCallback( [this]() { - const std::vector steps = global::timeManager.deltaTimeSteps(); + const std::vector steps = global::timeManager->deltaTimeSteps(); if (steps != _lastDeltaTimeSteps) { sendDeltaTimeSteps(); } @@ -110,8 +112,8 @@ void TimeTopic::handleJson(const nlohmann::json& json) { } const json TimeTopic::getNextPrevDeltaTimeStepJson() { - const std::optional nextStep = global::timeManager.nextDeltaTimeStep(); - const std::optional prevStep = global::timeManager.previousDeltaTimeStep(); + const std::optional nextStep = global::timeManager->nextDeltaTimeStep(); + const std::optional prevStep = global::timeManager->previousDeltaTimeStep(); const bool hasNext = nextStep.has_value(); const bool hasPrev = prevStep.has_value(); @@ -135,7 +137,7 @@ void TimeTopic::sendCurrentTime() { ZoneScoped const json timeJson = { - { "time", global::timeManager.time().ISO8601() } + { "time", global::timeManager->time().ISO8601() } }; const json payload = wrappedPayload(timeJson); _connection->sendJson(payload); @@ -143,10 +145,10 @@ void TimeTopic::sendCurrentTime() { } void TimeTopic::sendFullTimeData() { - std::string_view currentTime = global::timeManager.time().ISO8601(); - const double deltaTime = global::timeManager.deltaTime(); - const double targetDeltaTime = global::timeManager.targetDeltaTime(); - const bool isPaused = global::timeManager.isPaused(); + std::string_view currentTime = global::timeManager->time().ISO8601(); + const double deltaTime = global::timeManager->deltaTime(); + const double targetDeltaTime = global::timeManager->targetDeltaTime(); + const bool isPaused = global::timeManager->isPaused(); json timeJson = { { "time", currentTime }, @@ -165,7 +167,7 @@ void TimeTopic::sendFullTimeData() { } void TimeTopic::sendDeltaTimeSteps() { - const std::vector& steps = global::timeManager.deltaTimeSteps(); + const std::vector& steps = global::timeManager->deltaTimeSteps(); json deltaTimeStepsJson = { { "deltaTimeSteps", steps } diff --git a/modules/server/src/topics/triggerpropertytopic.cpp b/modules/server/src/topics/triggerpropertytopic.cpp index 8310e9346b..c489abbf5a 100644 --- a/modules/server/src/topics/triggerpropertytopic.cpp +++ b/modules/server/src/topics/triggerpropertytopic.cpp @@ -42,7 +42,7 @@ namespace openspace { void TriggerPropertyTopic::handleJson(const nlohmann::json& json) { try { const std::string& propertyKey = json.at(PropertyKey).get(); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( fmt::format( "openspace.setPropertyValueSingle(\"{}\", nil)", propertyKey ), diff --git a/modules/server/src/topics/versiontopic.cpp b/modules/server/src/topics/versiontopic.cpp index 033de54683..6dea1c8d5b 100644 --- a/modules/server/src/topics/versiontopic.cpp +++ b/modules/server/src/topics/versiontopic.cpp @@ -56,9 +56,9 @@ void VersionTopic::handleJson(const nlohmann::json&) { } }; - if (global::versionChecker.hasLatestVersionInfo()) { + if (global::versionChecker->hasLatestVersionInfo()) { VersionChecker::SemanticVersion latestVersion = - global::versionChecker.latestVersion(); + global::versionChecker->latestVersion(); versionJson["latestOpenSpaceVersion"] = { { "major", latestVersion.major }, diff --git a/modules/space/rendering/renderableconstellationbounds.cpp b/modules/space/rendering/renderableconstellationbounds.cpp index ed1b59373a..4e2ca10e91 100644 --- a/modules/space/rendering/renderableconstellationbounds.cpp +++ b/modules/space/rendering/renderableconstellationbounds.cpp @@ -205,7 +205,7 @@ RenderableConstellationBounds::RenderableConstellationBounds( } void RenderableConstellationBounds::initializeGL() { - _program = global::renderEngine.buildRenderProgram( + _program = global::renderEngine->buildRenderProgram( "ConstellationBounds", absPath("${MODULE_SPACE}/shaders/constellationbounds_vs.glsl"), absPath("${MODULE_SPACE}/shaders/constellationbounds_fs.glsl") @@ -237,7 +237,7 @@ void RenderableConstellationBounds::deinitializeGL() { _vao = 0; if (_program) { - global::renderEngine.removeRenderProgram(_program.get()); + global::renderEngine->removeRenderProgram(_program.get()); _program = nullptr; } } diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index 5e902942d2..0afe86fc94 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -432,7 +432,7 @@ void RenderableOrbitalKepler::initializeGL() { _programObject = SpaceModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_SPACE}/shaders/debrisViz_vs.glsl"), absPath("${MODULE_SPACE}/shaders/debrisViz_fs.glsl") @@ -457,7 +457,7 @@ void RenderableOrbitalKepler::deinitializeGL() { SpaceModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _programObject = nullptr; diff --git a/modules/space/rendering/renderablerings.cpp b/modules/space/rendering/renderablerings.cpp index 1291ccbe4d..4e882de4a0 100644 --- a/modules/space/rendering/renderablerings.cpp +++ b/modules/space/rendering/renderablerings.cpp @@ -182,7 +182,7 @@ bool RenderableRings::isReady() const { } void RenderableRings::initializeGL() { - _shader = global::renderEngine.buildRenderProgram( + _shader = global::renderEngine->buildRenderProgram( "RingProgram", absPath("${MODULE_SPACE}/shaders/rings_vs.glsl"), absPath("${MODULE_SPACE}/shaders/rings_fs.glsl") @@ -207,7 +207,7 @@ void RenderableRings::deinitializeGL() { _textureFile = nullptr; _texture = nullptr; - global::renderEngine.removeRenderProgram(_shader.get()); + global::renderEngine->removeRenderProgram(_shader.get()); _shader = nullptr; } @@ -261,7 +261,7 @@ void RenderableRings::update(const UpdateData& data) { _textureIsDirty = false; } - _sunPosition = global::renderEngine.scene()->sceneGraphNode("Sun")->worldPosition() - + _sunPosition = global::renderEngine->scene()->sceneGraphNode("Sun")->worldPosition() - data.modelTransform.translation; } diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index d39e55b22b..e51bfefd51 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -693,7 +693,7 @@ bool RenderableStars::isReady() const { } void RenderableStars::initializeGL() { - _program = global::renderEngine.buildRenderProgram( + _program = global::renderEngine->buildRenderProgram( "Star", absPath("${MODULE_SPACE}/shaders/star_vs.glsl"), absPath("${MODULE_SPACE}/shaders/star_fs.glsl"), @@ -803,7 +803,7 @@ void RenderableStars::deinitializeGL() { //_shapeTexture = nullptr; if (_program) { - global::renderEngine.removeRenderProgram(_program.get()); + global::renderEngine->removeRenderProgram(_program.get()); _program = nullptr; } } @@ -916,7 +916,7 @@ void RenderableStars::renderPSFToTexture() { //glDeleteFramebuffers(1, &convolveFBO); // Restores OpenGL blending state - global::renderEngine.openglStateCache().resetBlendState(); + global::renderEngine->openglStateCache().resetBlendState(); } void RenderableStars::render(const RenderData& data, RendererTasks&) { diff --git a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp index 02831af39a..e3a8f2d171 100644 --- a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp +++ b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp @@ -145,7 +145,7 @@ DashboardItemInstruments::DashboardItemInstruments(const ghoul::Dictionary& dict glm::vec3(0.f), glm::vec3(1.f) ) - , _font(global::fontManager.font(KeyFontMono, 10)) + , _font(global::fontManager->font(KeyFontMono, 10)) { documentation::testSpecificationAndThrow( Documentation(), @@ -161,12 +161,12 @@ DashboardItemInstruments::DashboardItemInstruments(const ghoul::Dictionary& dict } _fontName.onChange([this]() { - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontName); _fontSize.onChange([this]() { - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); }); addProperty(_fontSize); @@ -175,13 +175,13 @@ DashboardItemInstruments::DashboardItemInstruments(const ghoul::Dictionary& dict _activeFlash.setViewOption(properties::Property::ViewOptions::Color); addProperty(_activeFlash); - _font = global::fontManager.font(_fontName, _fontSize); + _font = global::fontManager->font(_fontName, _fontSize); } void DashboardItemInstruments::render(glm::vec2& penPosition) { ZoneScoped - double currentTime = global::timeManager.time().j2000Seconds(); + double currentTime = global::timeManager->time().j2000Seconds(); if (!ImageSequencer::ref().isReady()) { return; @@ -231,7 +231,7 @@ void DashboardItemInstruments::render(glm::vec2& penPosition) { ); std::string str = SpiceManager::ref().dateFromEphemerisTime( - sequencer.nextCaptureTime(global::timeManager.time().j2000Seconds()), + sequencer.nextCaptureTime(global::timeManager->time().j2000Seconds()), "YYYY MON DD HR:MN:SC" ); @@ -315,7 +315,7 @@ void DashboardItemInstruments::render(glm::vec2& penPosition) { glm::vec2 DashboardItemInstruments::size() const { glm::vec2 size = glm::vec2(0.f); //return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( - double currentTime = global::timeManager.time().j2000Seconds(); + double currentTime = global::timeManager->time().j2000Seconds(); if (!ImageSequencer::ref().isReady()) { return glm::vec2(0.f); diff --git a/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp b/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp index 2ba4d88f6c..425538476a 100644 --- a/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp +++ b/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp @@ -133,7 +133,7 @@ bool RenderableCrawlingLine::isReady() const { } void RenderableCrawlingLine::initializeGL() { - _program = global::renderEngine.buildRenderProgram( + _program = global::renderEngine->buildRenderProgram( "RenderableCrawlingLine", absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/crawlingline_vs.glsl"), absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/crawlingline_fs.glsl") @@ -169,7 +169,7 @@ void RenderableCrawlingLine::deinitializeGL() { _vbo = 0; if (_program) { - global::renderEngine.removeRenderProgram(_program.get()); + global::renderEngine->removeRenderProgram(_program.get()); _program = nullptr; } } diff --git a/modules/spacecraftinstruments/rendering/renderablefov.cpp b/modules/spacecraftinstruments/rendering/renderablefov.cpp index 9da17a57b1..a8ea7682e0 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.cpp +++ b/modules/spacecraftinstruments/rendering/renderablefov.cpp @@ -329,7 +329,7 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary) if (dictionary.hasKey(KeyFrameConversions)) { ghoul::Dictionary fc = dictionary.value(KeyFrameConversions); for (const std::string& key : fc.keys()) { - global::moduleEngine.module()->addFrame( + global::moduleEngine->module()->addFrame( key, fc.value(key) ); @@ -370,7 +370,7 @@ void RenderableFov::initializeGL() { SpacecraftInstrumentsModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_vs.glsl"), absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_fs.glsl") @@ -518,7 +518,7 @@ void RenderableFov::deinitializeGL() { SpacecraftInstrumentsModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _program = nullptr; @@ -562,10 +562,10 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& { const bool convert = (ref.find("IAU_") == std::string::npos); if (convert) { + SpacecraftInstrumentsModule* m = + global::moduleEngine->module(); return { - global::moduleEngine.module()->frameFromBody( - target - ), + m->frameFromBody(target), true }; } @@ -960,7 +960,9 @@ std::pair RenderableFov::determineTarget(double time) { bool inFOV = SpiceManager::ref().isTargetInFieldOfView( pt, _instrument.spacecraft, - global::moduleEngine.module()->frameFromBody(pt), + global::moduleEngine->module()->frameFromBody( + pt + ), _instrument.name, SpiceManager::FieldOfViewMethod::Ellipsoid, _instrument.aberrationCorrection, diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp index 083bd06bc4..8d5c76a77e 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp @@ -157,7 +157,7 @@ bool RenderableModelProjection::isReady() const { } void RenderableModelProjection::initializeGL() { - _programObject = global::renderEngine.buildRenderProgram( + _programObject = global::renderEngine->buildRenderProgram( "ModelShader", absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_vs.glsl"), absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_fs.glsl") @@ -213,7 +213,7 @@ void RenderableModelProjection::deinitializeGL() { _projectionComponent.deinitialize(); - global::renderEngine.removeRenderProgram(_programObject.get()); + global::renderEngine->removeRenderProgram(_programObject.get()); _programObject = nullptr; } @@ -347,9 +347,8 @@ void RenderableModelProjection::update(const UpdateData& data) { } } - // @TODO: Change this to remove PSC glm::dvec3 p = - global::renderEngine.scene()->sceneGraphNode("Sun")->worldPosition() - + global::renderEngine->scene()->sceneGraphNode("Sun")->worldPosition() - data.modelTransform.translation; _sunPosition = static_cast(p); diff --git a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp index 45882270f9..29e1768614 100644 --- a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp @@ -80,7 +80,7 @@ void RenderablePlaneProjection::initializeGL() { glGenVertexArrays(1, &_quad); glGenBuffers(1, &_vertexPositionBuffer); - _shader = global::renderEngine.buildRenderProgram( + _shader = global::renderEngine->buildRenderProgram( "Image Plane", absPath("${MODULE_BASE}/shaders/imageplane_vs.glsl"), absPath("${MODULE_BASE}/shaders/imageplane_fs.glsl") @@ -92,7 +92,7 @@ void RenderablePlaneProjection::initializeGL() { void RenderablePlaneProjection::deinitializeGL() { if (_shader) { - global::renderEngine.removeRenderProgram(_shader.get()); + global::renderEngine->removeRenderProgram(_shader.get()); _shader = nullptr; } @@ -253,8 +253,8 @@ void RenderablePlaneProjection::updatePlane(const Image& img, double currentTime } if (!_moving) { - SceneGraphNode* thisNode = global::renderEngine.scene()->sceneGraphNode(_name); - SceneGraphNode* newParent = global::renderEngine.scene()->sceneGraphNode( + SceneGraphNode* thisNode = global::renderEngine->scene()->sceneGraphNode(_name); + SceneGraphNode* newParent = global::renderEngine->scene()->sceneGraphNode( _target.node ); if (thisNode && newParent) { @@ -313,7 +313,7 @@ void RenderablePlaneProjection::setTarget(std::string body) { } _target.frame = - global::moduleEngine.module()->frameFromBody(body); + global::moduleEngine->module()->frameFromBody(body); _target.body = std::move(body); } diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index 238ad1cd11..e7adc0985c 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -360,7 +360,7 @@ void RenderablePlanetProjection::initializeGL() { SpacecraftInstrumentsModule::ProgramObjectManager.request( ProjectiveProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProjectiveProgramName, absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/" "renderablePlanet_vs.glsl" @@ -450,7 +450,7 @@ void RenderablePlanetProjection::deinitializeGL() { SpacecraftInstrumentsModule::ProgramObjectManager.release( ProjectiveProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _programObject = nullptr; diff --git a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp index df97458c92..76e3159a78 100644 --- a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp +++ b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp @@ -269,7 +269,7 @@ void RenderableShadowCylinder::initializeGL() { _shader = SpacecraftInstrumentsModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( + return global::renderEngine->buildRenderProgram( ProgramName, absPath( "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_vs.glsl" @@ -288,7 +288,7 @@ void RenderableShadowCylinder::deinitializeGL() { SpacecraftInstrumentsModule::ProgramObjectManager.release( ProgramName, [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); + global::renderEngine->removeRenderProgram(p); } ); _shader = nullptr; diff --git a/modules/sync/tasks/syncassettask.cpp b/modules/sync/tasks/syncassettask.cpp index 5ea8a551b1..5b69d7df55 100644 --- a/modules/sync/tasks/syncassettask.cpp +++ b/modules/sync/tasks/syncassettask.cpp @@ -94,7 +94,7 @@ void SyncAssetTask::perform(const Task::ProgressCallback& progressCallback) { registerCoreClasses(scriptEngine); - for (OpenSpaceModule* m : global::moduleEngine.modules()) { + for (OpenSpaceModule* m : global::moduleEngine->modules()) { scriptEngine.addLibrary(m->luaLibrary()); for (scripting::LuaLibrary& l : m->luaLibraries()) { diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index c31ac046ea..2d0a8b0802 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -376,7 +376,7 @@ void TouchInteraction::updateStateFromInput(const std::vector& _time = timestamp; } // Code for lower-right corner double-tap to zoom-out - const glm::vec2 res = global::windowDelegate.currentWindowSize(); + const glm::vec2 res = global::windowDelegate->currentWindowSize(); const glm::vec2 pos = list[0].latestInput().screenCoordinates(res); const float bottomCornerSizeForZoomTap_fraction = 0.08f; @@ -482,7 +482,7 @@ void TouchInteraction::findSelectedNode(const std::vector& lis "Kerberos", "Hydra", "Charon", "Tethys", "OsirisRex", "Bennu" }; std::vector selectableNodes; - for (SceneGraphNode* node : global::renderEngine.scene()->allSceneGraphNodes()) { + for (SceneGraphNode* node : global::renderEngine->scene()->allSceneGraphNodes()) { for (const std::string& name : selectables) { if (node->identifier() == name) { selectableNodes.push_back(node); @@ -755,7 +755,7 @@ void TouchInteraction::computeVelocities(const std::vector& li { const int action = interpretInteraction(list, lastProcessed); const SceneGraphNode* anchor = - global::navigationHandler.orbitalNavigator().anchorNode(); + global::navigationHandler->orbitalNavigator().anchorNode(); if (!anchor) { return; } @@ -784,7 +784,7 @@ void TouchInteraction::computeVelocities(const std::vector& li #endif const TouchInputHolder& inputHolder = list.at(0); - const glm::ivec2 windowSize = global::windowDelegate.currentWindowSize(); + const glm::ivec2 windowSize = global::windowDelegate->currentWindowSize(); const float aspectRatio = static_cast(windowSize.x) / static_cast(windowSize.y); switch (action) { @@ -917,14 +917,14 @@ double TouchInteraction::computeConstTimeDecayCoefficient(double velocity) { double TouchInteraction::computeTapZoomDistance(double zoomGain) { const SceneGraphNode* anchor = - global::navigationHandler.orbitalNavigator().anchorNode(); + global::navigationHandler->orbitalNavigator().anchorNode(); if (!anchor) { return 0.0; } double dist = glm::distance( _camera->positionVec3(), - global::navigationHandler.orbitalNavigator().anchorNode()->worldPosition() + global::navigationHandler->orbitalNavigator().anchorNode()->worldPosition() ); dist -= anchor->boundingSphere(); @@ -942,11 +942,11 @@ void TouchInteraction::step(double dt, bool directTouch) { using namespace glm; const SceneGraphNode* anchor = - global::navigationHandler.orbitalNavigator().anchorNode(); + global::navigationHandler->orbitalNavigator().anchorNode(); // since functions cant be called directly (TouchInteraction not a subclass of // InteractionMode) - setFocusNode(global::navigationHandler.orbitalNavigator().anchorNode()); + setFocusNode(global::navigationHandler->orbitalNavigator().anchorNode()); if (anchor && _camera) { // Create variables from current state dvec3 camPos = _camera->positionVec3(); @@ -1167,7 +1167,7 @@ void TouchInteraction::resetAfterInput() { _debugProperties.interactionMode = "None"; #endif if (_directTouchMode && !_selected.empty() && _lmSuccess) { - double spinDelta = _spinSensitivity / global::windowDelegate.averageDeltaTime(); + double spinDelta = _spinSensitivity / global::windowDelegate->averageDeltaTime(); if (glm::length(_lastVel.orbit) > _orbitSpeedThreshold) { // allow node to start "spinning" after direct-manipulation finger is let go _vel.orbit = _lastVel.orbit * spinDelta; @@ -1225,19 +1225,19 @@ Camera* TouchInteraction::getCamera() { } const SceneGraphNode* TouchInteraction::getFocusNode() { - return global::navigationHandler.orbitalNavigator().anchorNode(); + return global::navigationHandler->orbitalNavigator().anchorNode(); } void TouchInteraction::setCamera(Camera* camera) { _camera = camera; } void TouchInteraction::setFocusNode(const SceneGraphNode* focusNode) { if (focusNode) { - global::navigationHandler.orbitalNavigator().setAnchorNode( + global::navigationHandler->orbitalNavigator().setAnchorNode( focusNode->identifier() ); } else { - global::navigationHandler.orbitalNavigator().setAnchorNode(""); + global::navigationHandler->orbitalNavigator().setAnchorNode(""); } } diff --git a/modules/touch/src/touchmarker.cpp b/modules/touch/src/touchmarker.cpp index 8abd11e7e8..6ff732fb40 100644 --- a/modules/touch/src/touchmarker.cpp +++ b/modules/touch/src/touchmarker.cpp @@ -89,7 +89,7 @@ void TouchMarker::initialize() { glGenVertexArrays(1, &_quad); // generate array glGenBuffers(1, &_vertexPositionBuffer); // generate buffer - _shader = global::renderEngine.buildRenderProgram( + _shader = global::renderEngine->buildRenderProgram( "MarkerProgram", absPath("${MODULE_TOUCH}/shaders/marker_vs.glsl"), absPath("${MODULE_TOUCH}/shaders/marker_fs.glsl") @@ -106,7 +106,7 @@ void TouchMarker::deinitialize() { _vertexPositionBuffer = 0; if (_shader) { - global::renderEngine.removeRenderProgram(_shader.get()); + global::renderEngine->removeRenderProgram(_shader.get()); _shader = nullptr; } } diff --git a/modules/touch/src/win32_touch.cpp b/modules/touch/src/win32_touch.cpp index 7ac553205b..3e1640af86 100644 --- a/modules/touch/src/win32_touch.cpp +++ b/modules/touch/src/win32_touch.cpp @@ -121,7 +121,7 @@ LRESULT CALLBACK HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { std::unique_ptr points = std::make_unique(touchInput); gTouchInputsMap.emplace(info.pointerId, std::move(points)); - global::openSpaceEngine.touchDetectionCallback(touchInput); + global::openSpaceEngine->touchDetectionCallback(touchInput); #endif #ifdef ENABLE_TUIOMESSAGES // Handle new touchpoint @@ -139,7 +139,7 @@ LRESULT CALLBACK HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { TouchInputHolder* points = gTouchInputsMap[info.pointerId].get(); if (points->tryAddInput(touchInput)) { - global::openSpaceEngine.touchUpdateCallback(points->latestInput()); + global::openSpaceEngine->touchUpdateCallback(points->latestInput()); } #endif #ifdef ENABLE_TUIOMESSAGES @@ -155,7 +155,7 @@ LRESULT CALLBACK HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { else if (info.pointerFlags & POINTER_FLAG_UP) { #ifdef ENABLE_DIRECTMSG gTouchInputsMap.erase(info.pointerId); - global::openSpaceEngine.touchExitCallback(touchInput); + global::openSpaceEngine->touchExitCallback(touchInput); #endif #ifdef ENABLE_TUIOMESSAGES // Handle removed touchpoint diff --git a/modules/touch/touchmodule.cpp b/modules/touch/touchmodule.cpp index 1672b2cf42..dc80b46fac 100644 --- a/modules/touch/touchmodule.cpp +++ b/modules/touch/touchmodule.cpp @@ -67,7 +67,7 @@ bool TouchModule::processNewInput() { _touch.touchActive(!_touchPoints.empty()); if (!_touchPoints.empty()) { - global::interactionMonitor.markInteraction(); + global::interactionMonitor->markInteraction(); } // Erase old input id's that no longer exists @@ -197,7 +197,7 @@ void TouchModule::internalInitialize(const ghoul::Dictionary& /*dictionary*/){ #ifdef WIN32 // We currently only support one window of touch input internally // so here we grab the first window-handle and use it. - void* nativeWindowHandle = global::windowDelegate.getNativeWindowHandle(0); + void* nativeWindowHandle = global::windowDelegate->getNativeWindowHandle(0); if (nativeWindowHandle) { _win32TouchHook = std::make_unique(nativeWindowHandle); } @@ -231,10 +231,10 @@ void TouchModule::internalInitialize(const ghoul::Dictionary& /*dictionary*/){ global::callback::preSync.push_back([&]() { - _touch.setCamera(global::navigationHandler.camera()); - _touch.setFocusNode(global::navigationHandler.orbitalNavigator().anchorNode()); + _touch.setCamera(global::navigationHandler->camera()); + _touch.setFocusNode(global::navigationHandler->orbitalNavigator().anchorNode()); - if (processNewInput() && global::windowDelegate.isMaster() && _touchActive) { + if (processNewInput() && global::windowDelegate->isMaster() && _touchActive) { _touch.updateStateFromInput(_touchPoints, _lastTouchInputs); } else if (_touchPoints.empty()) { @@ -247,7 +247,7 @@ void TouchModule::internalInitialize(const ghoul::Dictionary& /*dictionary*/){ _lastTouchInputs.emplace_back(points.latestInput()); } // calculate the new camera state for this frame - _touch.step(global::windowDelegate.deltaTime()); + _touch.step(global::windowDelegate->deltaTime()); clearInputs(); }); diff --git a/modules/toyvolume/rendering/renderabletoyvolume.cpp b/modules/toyvolume/rendering/renderabletoyvolume.cpp index 7a3d3b9479..be0ce3d6b4 100644 --- a/modules/toyvolume/rendering/renderabletoyvolume.cpp +++ b/modules/toyvolume/rendering/renderabletoyvolume.cpp @@ -145,14 +145,14 @@ void RenderableToyVolume::initializeGL() { _raycaster = std::make_unique(color); _raycaster->initialize(); - global::raycasterManager.attachRaycaster(*_raycaster.get()); + global::raycasterManager->attachRaycaster(*_raycaster.get()); std::function onChange = [&](bool enabled) { if (enabled) { - global::raycasterManager.attachRaycaster(*_raycaster.get()); + global::raycasterManager->attachRaycaster(*_raycaster.get()); } else { - global::raycasterManager.detachRaycaster(*_raycaster.get()); + global::raycasterManager->detachRaycaster(*_raycaster.get()); } }; @@ -170,7 +170,7 @@ void RenderableToyVolume::initializeGL() { void RenderableToyVolume::deinitializeGL() { if (_raycaster) { - global::raycasterManager.detachRaycaster(*_raycaster.get()); + global::raycasterManager->detachRaycaster(*_raycaster.get()); _raycaster = nullptr; } } diff --git a/modules/vislab/rendering/renderabledistancelabel.cpp b/modules/vislab/rendering/renderabledistancelabel.cpp index db6d3c0cef..4936e7dcc8 100644 --- a/modules/vislab/rendering/renderabledistancelabel.cpp +++ b/modules/vislab/rendering/renderabledistancelabel.cpp @@ -122,7 +122,7 @@ void RenderableDistanceLabel::update(const UpdateData&) { return; } - RenderEngine& RE = global::renderEngine; + RenderEngine& RE = *global::renderEngine; SceneGraphNode* nodelineNode = RE.scene()->sceneGraphNode(_nodelineId); if (nodelineNode) { diff --git a/modules/volume/rendering/renderabletimevaryingvolume.cpp b/modules/volume/rendering/renderabletimevaryingvolume.cpp index 0cad00ee51..61eac27267 100644 --- a/modules/volume/rendering/renderabletimevaryingvolume.cpp +++ b/modules/volume/rendering/renderabletimevaryingvolume.cpp @@ -298,13 +298,13 @@ void RenderableTimeVaryingVolume::initializeGL() { ); _raycaster->initialize(); - global::raycasterManager.attachRaycaster(*_raycaster.get()); + global::raycasterManager->attachRaycaster(*_raycaster.get()); onEnabledChange([&](bool enabled) { if (enabled) { - global::raycasterManager.attachRaycaster(*_raycaster.get()); + global::raycasterManager->attachRaycaster(*_raycaster.get()); } else { - global::raycasterManager.detachRaycaster(*_raycaster.get()); + global::raycasterManager->detachRaycaster(*_raycaster.get()); } }); @@ -366,7 +366,7 @@ RenderableTimeVaryingVolume::Timestep* RenderableTimeVaryingVolume::currentTimes if (_volumeTimesteps.empty()) { return nullptr; } - double currentTime = global::timeManager.time().j2000Seconds(); + double currentTime = global::timeManager->time().j2000Seconds(); // Get the first item with time > currentTime auto currentTimestepIt = _volumeTimesteps.upper_bound(currentTime); @@ -427,7 +427,7 @@ RenderableTimeVaryingVolume::Timestep* RenderableTimeVaryingVolume::timestepFrom void RenderableTimeVaryingVolume::jumpToTimestep(int target) { Timestep* t = timestepFromIndex(target); if (t) { - global::timeManager.setTimeNextFrame(Time(t->metadata.time)); + global::timeManager->setTimeNextFrame(Time(t->metadata.time)); } } @@ -487,7 +487,7 @@ bool RenderableTimeVaryingVolume::isReady() const { void RenderableTimeVaryingVolume::deinitializeGL() { if (_raycaster) { - global::raycasterManager.detachRaycaster(*_raycaster.get()); + global::raycasterManager->detachRaycaster(*_raycaster.get()); _raycaster = nullptr; } } diff --git a/modules/webbrowser/src/browserinstance.cpp b/modules/webbrowser/src/browserinstance.cpp index 14eaaef9b0..6899eb8e3f 100644 --- a/modules/webbrowser/src/browserinstance.cpp +++ b/modules/webbrowser/src/browserinstance.cpp @@ -75,8 +75,8 @@ BrowserInstance::~BrowserInstance() { void BrowserInstance::initialize() { reshape(static_cast( - static_cast(global::windowDelegate.currentSubwindowSize()) * - global::windowDelegate.dpiScaling() + static_cast(global::windowDelegate->currentSubwindowSize()) * + global::windowDelegate->dpiScaling() )); _isInitialized = true; _shouldReshape = true; @@ -170,7 +170,7 @@ bool BrowserInstance::sendMouseWheelEvent(const CefMouseEvent& event, } void BrowserInstance::setZoom(float ratio) { - const float dpiScaling = global::windowDelegate.dpiScaling().x; + const float dpiScaling = global::windowDelegate->dpiScaling().x; // Zooming in CEF is non-linear according to this: // https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=11491 diff --git a/modules/webbrowser/src/eventhandler.cpp b/modules/webbrowser/src/eventhandler.cpp index 9607457a30..da9ca87185 100644 --- a/modules/webbrowser/src/eventhandler.cpp +++ b/modules/webbrowser/src/eventhandler.cpp @@ -332,7 +332,7 @@ bool EventHandler::mouseButtonCallback(MouseButton button, MouseAction action, return false; } - global::interactionMonitor.markInteraction(); + global::interactionMonitor->markInteraction(); MouseButtonState& state = (button == MouseButton::Left) ? _leftButton : _rightButton; int clickCount = BrowserInstance::SingleClick; @@ -381,11 +381,11 @@ bool EventHandler::isDoubleClick(const MouseButtonState& button) const { } bool EventHandler::mousePositionCallback(double x, double y) { - const glm::vec2 dpiScaling = global::windowDelegate.dpiScaling(); + const glm::vec2 dpiScaling = global::windowDelegate->dpiScaling(); _mousePosition.x = floor(static_cast(x) * dpiScaling.x); _mousePosition.y = floor(static_cast(y) * dpiScaling.y); _browserInstance->sendMouseMoveEvent(mouseEvent()); - global::interactionMonitor.markInteraction(); + global::interactionMonitor->markInteraction(); // Let the mouse event trickle on return false; @@ -476,7 +476,7 @@ CefTouchEvent EventHandler::touchEvent(const TouchInput& input, event.y = windowPos.y; event.type = eventType; const std::vector>& keyModVec = - global::navigationHandler.inputState().pressedKeys(); + global::navigationHandler->inputState().pressedKeys(); for (const std::pair& keyModPair : keyModVec) { const KeyModifier mods = keyModPair.second; event.modifiers |= static_cast(mapToCefModifiers(mods)); diff --git a/modules/webbrowser/src/screenspacebrowser.cpp b/modules/webbrowser/src/screenspacebrowser.cpp index 84ff5ce0cb..f1f3993294 100644 --- a/modules/webbrowser/src/screenspacebrowser.cpp +++ b/modules/webbrowser/src/screenspacebrowser.cpp @@ -87,7 +87,7 @@ ScreenSpaceBrowser::ScreenSpaceBrowser(const ghoul::Dictionary &dictionary) _url = dictionary.value(UrlInfo.identifier); } - glm::vec2 windowDimensions = global::windowDelegate.currentSubwindowSize(); + glm::vec2 windowDimensions = global::windowDelegate->currentSubwindowSize(); _dimensions = windowDimensions; _renderHandler = new ScreenSpaceRenderHandler(); @@ -105,7 +105,7 @@ ScreenSpaceBrowser::ScreenSpaceBrowser(const ghoul::Dictionary &dictionary) addProperty(_dimensions); addProperty(_reload); - WebBrowserModule* webBrowser = global::moduleEngine.module(); + WebBrowserModule* webBrowser = global::moduleEngine->module(); if (webBrowser) { webBrowser->addBrowser(_browserInstance.get()); } @@ -135,7 +135,7 @@ bool ScreenSpaceBrowser::deinitializeGL() { _browserInstance->close(true); - WebBrowserModule* webBrowser = global::moduleEngine.module(); + WebBrowserModule* webBrowser = global::moduleEngine->module(); if (webBrowser) { webBrowser->removeBrowser(_browserInstance.get()); _browserInstance.reset(); diff --git a/modules/webbrowser/webbrowsermodule.cpp b/modules/webbrowser/webbrowsermodule.cpp index d75ddf4959..33a5fe0f46 100644 --- a/modules/webbrowser/webbrowsermodule.cpp +++ b/modules/webbrowser/webbrowsermodule.cpp @@ -138,7 +138,7 @@ void WebBrowserModule::internalInitialize(const ghoul::Dictionary& dictionary) { _enabled = dictionary.value("Enabled"); } - const bool isMaster = global::windowDelegate.isMaster(); + const bool isMaster = global::windowDelegate->isMaster(); if (!_enabled || (!isMaster) ) { return; diff --git a/modules/webgui/webguimodule.cpp b/modules/webgui/webguimodule.cpp index ae0d3079fd..aa09e84e0b 100644 --- a/modules/webgui/webguimodule.cpp +++ b/modules/webgui/webguimodule.cpp @@ -231,7 +231,7 @@ void WebGuiModule::startProcess() { _endpoints.clear(); - ServerModule* serverModule = global::moduleEngine.module(); + ServerModule* serverModule = global::moduleEngine->module(); const ServerInterface* serverInterface = serverModule->serverInterfaceByIdentifier(_webSocketInterface); if (!serverInterface) { diff --git a/src/engine/globals.cpp b/src/engine/globals.cpp index 8a28ea5070..67f65513f9 100644 --- a/src/engine/globals.cpp +++ b/src/engine/globals.cpp @@ -58,188 +58,198 @@ #include #include #include +#include + +namespace openspace { +namespace { + constexpr const int TotalSize = + sizeof(ghoul::fontrendering::FontManager) + + sizeof(Dashboard) + + sizeof(DeferredcasterManager) + + sizeof(DownloadManager) + + sizeof(LuaConsole) + + sizeof(MemoryManager) + + sizeof(MissionManager) + + sizeof(ModuleEngine) + + sizeof(OpenSpaceEngine) + + sizeof(ParallelPeer) + + sizeof(RaycasterManager) + + sizeof(RenderEngine) + + sizeof(std::vector>) + + sizeof(SyncEngine) + + sizeof(TimeManager) + + sizeof(VersionChecker) + + sizeof(VirtualPropertyManager) + + sizeof(WindowDelegate) + + sizeof(configuration::Configuration) + + sizeof(interaction::InteractionMonitor) + + sizeof(interaction::WebsocketInputStates) + + sizeof(interaction::KeybindingManager) + + sizeof(interaction::NavigationHandler) + + sizeof(interaction::SessionRecording) + + sizeof(interaction::ShortcutManager) + + sizeof(properties::PropertyOwner) + + sizeof(properties::PropertyOwner) + + sizeof(scripting::ScriptEngine) + + sizeof(scripting::ScriptScheduler) + + sizeof(Profile); + + std::array DataStorage; +} // namespace +} // namespace openspace namespace openspace::global { -namespace detail { +void create() { + ZoneScoped -ghoul::fontrendering::FontManager& gFontManager() { - static ghoul::fontrendering::FontManager g({ 1536, 1536, 1 }); - return g; + std::byte* currentPos = DataStorage.data(); + + fontManager = new (currentPos) ghoul::fontrendering::FontManager({ 1536, 1536, 1 }); + assert(fontManager); + currentPos += sizeof(ghoul::fontrendering::FontManager); + + dashboard = new (currentPos) Dashboard; + assert(dashboard); + currentPos += sizeof(Dashboard); + + deferredcasterManager = new (currentPos) DeferredcasterManager; + assert(deferredcasterManager); + currentPos += sizeof(DeferredcasterManager); + + downloadManager = new (currentPos) DownloadManager; + assert(downloadManager); + currentPos += sizeof(DownloadManager); + + luaConsole = new (currentPos) LuaConsole; + assert(luaConsole); + currentPos += sizeof(LuaConsole); + + memoryManager = new (currentPos) MemoryManager; + assert(memoryManager); + currentPos += sizeof(MemoryManager); + + missionManager = new (currentPos) MissionManager; + assert(missionManager); + currentPos += sizeof(MissionManager); + + moduleEngine = new (currentPos) ModuleEngine; + assert(moduleEngine); + currentPos += sizeof(ModuleEngine); + + openSpaceEngine = new (currentPos) OpenSpaceEngine; + assert(openSpaceEngine); + currentPos += sizeof(OpenSpaceEngine); + + parallelPeer = new (currentPos) ParallelPeer; + assert(parallelPeer); + currentPos += sizeof(ParallelPeer); + + raycasterManager = new (currentPos) RaycasterManager; + assert(raycasterManager); + currentPos += sizeof(RaycasterManager); + + renderEngine = new (currentPos) RenderEngine; + assert(renderEngine); + currentPos += sizeof(RenderEngine); + + screenSpaceRenderables = new (currentPos) std::vector>; + assert(screenSpaceRenderables); + currentPos += sizeof(std::vector>); + + syncEngine = new (currentPos) SyncEngine(4096); + assert(syncEngine); + currentPos += sizeof(SyncEngine); + + timeManager = new (currentPos) TimeManager; + assert(timeManager); + currentPos += sizeof(TimeManager); + + versionChecker = new (currentPos) VersionChecker; + assert(versionChecker); + currentPos += sizeof(VersionChecker); + + virtualPropertyManager = new (currentPos) VirtualPropertyManager; + assert(virtualPropertyManager); + currentPos += sizeof(VirtualPropertyManager); + + windowDelegate = new (currentPos) WindowDelegate; + assert(windowDelegate); + currentPos += sizeof(WindowDelegate); + + configuration = new (currentPos) configuration::Configuration; + assert(configuration); + currentPos += sizeof(configuration::Configuration); + + interactionMonitor = new (currentPos) interaction::InteractionMonitor; + assert(interactionMonitor); + currentPos += sizeof(interaction::InteractionMonitor); + + joystickInputStates = new (currentPos) interaction::JoystickInputStates; + assert(joystickInputStates); + currentPos += sizeof(interaction::JoystickInputStates); + + websocketInputStates = new (currentPos) interaction::WebsocketInputStates; + assert(websocketInputStates); + currentPos += sizeof(interaction::WebsocketInputStates); + + keybindingManager = new (currentPos) interaction::KeybindingManager; + assert(keybindingManager); + currentPos += sizeof(interaction::KeybindingManager); + + navigationHandler = new (currentPos) interaction::NavigationHandler; + assert(navigationHandler); + currentPos += sizeof(interaction::NavigationHandler); + + sessionRecording = new (currentPos) interaction::SessionRecording; + assert(sessionRecording); + currentPos += sizeof(interaction::SessionRecording); + + shortcutManager = new (currentPos) interaction::ShortcutManager; + assert(shortcutManager); + currentPos += sizeof(interaction::ShortcutManager); + + rootPropertyOwner = new (currentPos) properties::PropertyOwner({ "" }); + assert(rootPropertyOwner); + currentPos += sizeof(properties::PropertyOwner); + + screenSpaceRootPropertyOwner = new (currentPos) properties::PropertyOwner({ "ScreenSpace" }); + assert(screenSpaceRootPropertyOwner); + currentPos += sizeof(properties::PropertyOwner); + + scriptEngine = new (currentPos) scripting::ScriptEngine; + assert(scriptEngine); + currentPos += sizeof(scripting::ScriptEngine); + + scriptScheduler = new (currentPos) scripting::ScriptScheduler; + assert(scriptScheduler); + currentPos += sizeof(scripting::ScriptScheduler); + + profile = new (currentPos) Profile; + assert(profile); + currentPos += sizeof(Profile); } -Dashboard& gDashboard() { - static Dashboard g; - return g; -} - -DeferredcasterManager& gDeferredcasterManager() { - static DeferredcasterManager g; - return g; -} - -DownloadManager& gDownloadManager() { - static DownloadManager g; - return g; -} - -LuaConsole& gLuaConsole() { - static LuaConsole g; - return g; -} - -MemoryManager& gMemoryManager() { - static MemoryManager g; - return g; -} - -MissionManager& gMissionManager() { - static MissionManager g; - return g; -} - -ModuleEngine& gModuleEngine() { - static ModuleEngine g; - return g; -} - -OpenSpaceEngine& gOpenSpaceEngine() { - static OpenSpaceEngine g; - return g; -} - -ParallelPeer& gParallelPeer() { - static ParallelPeer g; - return g; -} - -RaycasterManager& gRaycasterManager() { - static RaycasterManager g; - return g; -} - -RenderEngine& gRenderEngine() { - static RenderEngine g; - return g; -} - -std::vector>& gScreenspaceRenderables() { - static std::vector> g; - return g; -} - -SyncEngine& gSyncEngine() { - static SyncEngine g(4096); - return g; -} - -TimeManager& gTimeManager() { - static TimeManager g; - return g; -} - -VersionChecker& gVersionChecker() { - static VersionChecker g; - return g; -} - -VirtualPropertyManager& gVirtualPropertyManager() { - static VirtualPropertyManager g; - return g; -} - -WindowDelegate& gWindowDelegate() { - static WindowDelegate g; - return g; -} - -configuration::Configuration& gConfiguration() { - static configuration::Configuration g; - return g; -} - -interaction::InteractionMonitor& gInteractionMonitor() { - static interaction::InteractionMonitor g; - return g; -} - -interaction::JoystickInputStates& gJoystickInputStates() { - static interaction::JoystickInputStates g; - return g; -} - -interaction::WebsocketInputStates& gWebsocketInputStates() { - static interaction::WebsocketInputStates g; - return g; -} - -interaction::KeybindingManager& gKeybindingManager() { - static interaction::KeybindingManager g; - return g; -} - -interaction::NavigationHandler& gNavigationHandler() { - static interaction::NavigationHandler g; - return g; -} - -interaction::SessionRecording& gSessionRecording() { - static interaction::SessionRecording g; - return g; -} - -interaction::ShortcutManager& gShortcutManager() { - static interaction::ShortcutManager g; - return g; -} - -properties::PropertyOwner& gRootPropertyOwner() { - static properties::PropertyOwner g({ "" }); - return g; -} - -properties::PropertyOwner& gScreenSpaceRootPropertyOwner() { - static properties::PropertyOwner g({ "ScreenSpace" }); - return g; -} - -scripting::ScriptEngine& gScriptEngine() { - static scripting::ScriptEngine g; - return g; -} - -scripting::ScriptScheduler& gScriptScheduler() { - static scripting::ScriptScheduler g; - return g; -} - -Profile& gProfile() { - static Profile g; - return g; -} - -} // namespace detail - void initialize() { ZoneScoped - global::rootPropertyOwner.addPropertySubOwner(global::moduleEngine); + rootPropertyOwner->addPropertySubOwner(global::moduleEngine); - global::navigationHandler.setPropertyOwner(&global::rootPropertyOwner); + navigationHandler->setPropertyOwner(global::rootPropertyOwner); // New property subowners also have to be added to the ImGuiModule callback! - global::rootPropertyOwner.addPropertySubOwner(global::navigationHandler); - global::rootPropertyOwner.addPropertySubOwner(global::interactionMonitor); - global::rootPropertyOwner.addPropertySubOwner(global::sessionRecording); - global::rootPropertyOwner.addPropertySubOwner(global::timeManager); + rootPropertyOwner->addPropertySubOwner(global::navigationHandler); + rootPropertyOwner->addPropertySubOwner(global::interactionMonitor); + rootPropertyOwner->addPropertySubOwner(global::sessionRecording); + rootPropertyOwner->addPropertySubOwner(global::timeManager); - global::rootPropertyOwner.addPropertySubOwner(global::renderEngine); - global::rootPropertyOwner.addPropertySubOwner(global::screenSpaceRootPropertyOwner); + rootPropertyOwner->addPropertySubOwner(global::renderEngine); + rootPropertyOwner->addPropertySubOwner(global::screenSpaceRootPropertyOwner); - global::rootPropertyOwner.addPropertySubOwner(global::parallelPeer); - global::rootPropertyOwner.addPropertySubOwner(global::luaConsole); - global::rootPropertyOwner.addPropertySubOwner(global::dashboard); + rootPropertyOwner->addPropertySubOwner(global::parallelPeer); + rootPropertyOwner->addPropertySubOwner(global::luaConsole); + rootPropertyOwner->addPropertySubOwner(global::dashboard); - global::syncEngine.addSyncable(&global::scriptEngine); + syncEngine->addSyncable(global::scriptEngine); } void initializeGL() { @@ -247,30 +257,127 @@ void initializeGL() { } +void destroy() { + LDEBUGC("Globals", "Destroying 'Profile'"); + profile->~Profile(); + + LDEBUGC("Globals", "Destroying 'ScriptScheduler'"); + scriptScheduler->~ScriptScheduler(); + + LDEBUGC("Globals", "Destroying 'ScriptEngine'"); + scriptEngine->~ScriptEngine(); + + LDEBUGC("Globals", "Destroying 'ScreenSpace Root Owner'"); + screenSpaceRootPropertyOwner->~PropertyOwner(); + + LDEBUGC("Globals", "Destroying 'Root Owner'"); + rootPropertyOwner->~PropertyOwner(); + + LDEBUGC("Globals", "Destroying 'ShortcutManager'"); + shortcutManager->~ShortcutManager(); + + LDEBUGC("Globals", "Destroying 'SessionRecording'"); + sessionRecording->~SessionRecording(); + + LDEBUGC("Globals", "Destroying 'NavigationHandler'"); + navigationHandler->~NavigationHandler(); + + LDEBUGC("Globals", "Destroying 'KeybindingManager'"); + keybindingManager->~KeybindingManager(); + + LDEBUGC("Globals", "Destroying 'WebsocketInputStates'"); + websocketInputStates->~WebsocketInputStates(); + + LDEBUGC("Globals", "Destroying 'JoystickInputStates'"); + joystickInputStates->~JoystickInputStates(); + + LDEBUGC("Globals", "Destroying 'InteractionMonitor'"); + interactionMonitor->~InteractionMonitor(); + + LDEBUGC("Globals", "Destroying 'Configuration'"); + configuration->~Configuration(); + + LDEBUGC("Globals", "Destroying 'WindowDelegate'"); + windowDelegate->~WindowDelegate(); + + LDEBUGC("Globals", "Destroying 'VirtualPropertyManager'"); + virtualPropertyManager->~VirtualPropertyManager(); + + LDEBUGC("Globals", "Destroying 'VersionChecker'"); + versionChecker->~VersionChecker(); + + LDEBUGC("Globals", "Destroying 'TimeManager'"); + timeManager->~TimeManager(); + + LDEBUGC("Globals", "Destroying 'SyncEngine'"); + syncEngine->~SyncEngine(); + + LDEBUGC("Globals", "Destroying 'ScreenSpaceRenderables'"); + screenSpaceRenderables->~vector>(); + + LDEBUGC("Globals", "Destroying 'RenderEngine'"); + renderEngine->~RenderEngine(); + + LDEBUGC("Globals", "Destroying 'RaycasterManager'"); + raycasterManager->~RaycasterManager(); + + LDEBUGC("Globals", "Destroying 'ParallelPeer'"); + parallelPeer->~ParallelPeer(); + + LDEBUGC("Globals", "Destroying 'OpenSpaceEngine'"); + openSpaceEngine->~OpenSpaceEngine(); + + LDEBUGC("Globals", "Destroying 'ModuleEngine'"); + moduleEngine->~ModuleEngine(); + + LDEBUGC("Globals", "Destroying 'MissionManager'"); + missionManager->~MissionManager(); + + LDEBUGC("Globals", "Destroying 'MemoryManager'"); + memoryManager->~MemoryManager(); + + LDEBUGC("Globals", "Destroying 'LuaConsole'"); + luaConsole->~LuaConsole(); + + LDEBUGC("Globals", "Destroying 'DownloadManager'"); + downloadManager->~DownloadManager(); + + LDEBUGC("Globals", "Destroying 'DeferredcasterManager'"); + deferredcasterManager->~DeferredcasterManager(); + + LDEBUGC("Globals", "Destroying 'Dashboard'"); + dashboard->~Dashboard(); + + LDEBUGC("Globals", "Destroying 'FontManager'"); + fontManager->~FontManager(); + + std::fill(DataStorage.begin(), DataStorage.end(), std::byte(0)); +} + void deinitialize() { ZoneScoped - for (std::unique_ptr& ssr : global::screenSpaceRenderables) { + for (std::unique_ptr& ssr : *screenSpaceRenderables) { ssr->deinitialize(); } - global::syncEngine.removeSyncables(global::timeManager.getSyncables()); + syncEngine->removeSyncables(timeManager->getSyncables()); - global::moduleEngine.deinitialize(); - global::luaConsole.deinitialize(); - global::scriptEngine.deinitialize(); - global::fontManager.deinitialize(); + moduleEngine->deinitialize(); + luaConsole->deinitialize(); + scriptEngine->deinitialize(); + fontManager->deinitialize(); } void deinitializeGL() { ZoneScoped - for (std::unique_ptr& ssr : global::screenSpaceRenderables) { + for (std::unique_ptr& ssr : *screenSpaceRenderables) { ssr->deinitializeGL(); } - global::renderEngine.deinitializeGL(); - global::moduleEngine.deinitializeGL(); + renderEngine->deinitializeGL(); + moduleEngine->deinitializeGL(); } } // namespace openspace::global diff --git a/src/engine/moduleengine_lua.inl b/src/engine/moduleengine_lua.inl index 230ca92243..6a70dea095 100644 --- a/src/engine/moduleengine_lua.inl +++ b/src/engine/moduleengine_lua.inl @@ -45,7 +45,7 @@ int isLoaded(lua_State* L) { ghoul::lua::PopValue::Yes ); - const std::vector& modules = global::moduleEngine.modules(); + const std::vector& modules = global::moduleEngine->modules(); auto it = std::find_if( modules.begin(), diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 44e83d17cd..61442d56c8 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -154,7 +154,7 @@ void OpenSpaceEngine::registerPathTokens() { // Registering Path tokens. If the BASE path is set, it is the only one that will // overwrite the default path of the cfg directory using T = std::string; - for (const std::pair& path : global::configuration.pathTokens) { + for (const std::pair& path : global::configuration->pathTokens) { std::string fullKey = ghoul::filesystem::FileSystem::TokenOpeningBraces + path.first + ghoul::filesystem::FileSystem::TokenClosingBraces; @@ -184,14 +184,14 @@ void OpenSpaceEngine::initialize() { global::initialize(); - const std::string versionCheckUrl = global::configuration.versionCheckUrl; + const std::string versionCheckUrl = global::configuration->versionCheckUrl; if (!versionCheckUrl.empty()) { - global::versionChecker.requestLatestVersion(versionCheckUrl); + global::versionChecker->requestLatestVersion(versionCheckUrl); } std::string cacheFolder = absPath("${CACHE}"); - if (global::configuration.usePerSceneCache) { - std::string scene = global::configuration.asset; + if (global::configuration->usePerSceneCache) { + std::string scene = global::configuration->asset; cacheFolder += "-" + ghoul::filesystem::File(scene).baseName(); LINFO(fmt::format("Old cache: {}", absPath("${CACHE}"))); @@ -228,15 +228,15 @@ void OpenSpaceEngine::initialize() { } ghoul::logging::LogLevel level = ghoul::from_string( - global::configuration.logging.level + global::configuration->logging.level ); - bool immediateFlush = global::configuration.logging.forceImmediateFlush; + bool immediateFlush = global::configuration->logging.forceImmediateFlush; using ImmediateFlush = ghoul::logging::LogManager::ImmediateFlush; ghoul::logging::LogManager::initialize(level, ImmediateFlush(immediateFlush)); LogMgr.addLog(std::make_unique()); - for (const ghoul::Dictionary& log : global::configuration.logging.logs) { + for (const ghoul::Dictionary& log : global::configuration->logging.logs) { try { LogMgr.addLog(createLog(log)); } @@ -273,11 +273,11 @@ void OpenSpaceEngine::initialize() { LINFOC("Commit", std::string(OPENSPACE_GIT_FULL)); // Register modules - global::moduleEngine.initialize(global::configuration.moduleConfigurations); + global::moduleEngine->initialize(global::configuration->moduleConfigurations); // After registering the modules, the documentations for the available classes // can be added as well - for (OpenSpaceModule* m : global::moduleEngine.modules()) { + for (OpenSpaceModule* m : global::moduleEngine->modules()) { for (const documentation::Documentation& doc : m->documentations()) { DocEng.addDocumentation(doc); } @@ -289,15 +289,15 @@ void OpenSpaceEngine::initialize() { // Register Lua script functions LDEBUG("Registering Lua libraries"); - registerCoreClasses(global::scriptEngine); + registerCoreClasses(*global::scriptEngine); // Convert profile to scene file (if was provided in configuration file) - if (!global::configuration.profile.empty()) { + if (!global::configuration->profile.empty()) { std::string inputProfilePath = absPath("${PROFILES}"); std::string outputScenePath = absPath("${TEMPORARY}"); - std::string inputProfile = inputProfilePath + "/" + global::configuration.profile + std::string inputProfile = inputProfilePath + "/" + global::configuration->profile + ".profile"; - std::string outputAsset = outputScenePath + "/" + global::configuration.profile + std::string outputAsset = outputScenePath + "/" + global::configuration->profile + ".asset"; if (!FileSys.fileExists(inputProfile)) { @@ -322,39 +322,41 @@ void OpenSpaceEngine::initialize() { (std::istreambuf_iterator(inFile)), std::istreambuf_iterator() ); - global::profile = Profile(content); + *global::profile = Profile(content); // Then save the profile to a scene so that we can load it with the // existing infrastructure std::ofstream scene(outputAsset); - std::string sceneContent = global::profile.convertToScene(); + std::string sceneContent = global::profile->convertToScene(); scene << sceneContent; // Set asset name to that of the profile because a new scene file will be // created with that name, and also because the profile name will override // an asset name if both are provided. - global::configuration.asset = outputAsset; - global::configuration.usingProfile = true; + global::configuration->asset = outputAsset; + global::configuration->usingProfile = true; } } // Set up asset loader - global::openSpaceEngine._assetManager = std::make_unique( - global::scriptEngine.luaState(), + global::openSpaceEngine->_assetManager = std::make_unique( + global::scriptEngine->luaState(), FileSys.absPath("${ASSETS}") ); - global::scriptEngine.addLibrary(global::openSpaceEngine._assetManager->luaLibrary()); + global::scriptEngine->addLibrary( + global::openSpaceEngine->_assetManager->luaLibrary() + ); - for (OpenSpaceModule* module : global::moduleEngine.modules()) { - global::scriptEngine.addLibrary(module->luaLibrary()); + for (OpenSpaceModule* module : global::moduleEngine->modules()) { + global::scriptEngine->addLibrary(module->luaLibrary()); for (scripting::LuaLibrary& l : module->luaLibraries()) { - global::scriptEngine.addLibrary(l); + global::scriptEngine->addLibrary(l); } } - global::scriptEngine.initialize(); + global::scriptEngine->initialize(); // To be concluded _documentationJson.clear(); @@ -362,11 +364,11 @@ void OpenSpaceEngine::initialize() { writeStaticDocumentation(); - _shutdown.waitTime = global::configuration.shutdownCountdown; + _shutdown.waitTime = global::configuration->shutdownCountdown; - global::navigationHandler.initialize(); + global::navigationHandler->initialize(); - global::renderEngine.initialize(); + global::renderEngine->initialize(); for (const std::function& func : global::callback::initialize) { ZoneScopedN("[Module] initialize") @@ -374,8 +376,8 @@ void OpenSpaceEngine::initialize() { func(); } - global::openSpaceEngine._assetManager->initialize(); - scheduleLoadSingleAsset(global::configuration.asset); + global::openSpaceEngine->_assetManager->initialize(); + scheduleLoadSingleAsset(global::configuration->asset); LTRACE("OpenSpaceEngine::initialize(end)"); } @@ -397,7 +399,7 @@ std::string OpenSpaceEngine::generateFilePath(std::string openspaceRelativePath) else { path.append("/"); } - return path.append(global::configuration.profile); + return path.append(global::configuration->profile); } void OpenSpaceEngine::initializeGL() { @@ -405,7 +407,7 @@ void OpenSpaceEngine::initializeGL() { LTRACE("OpenSpaceEngine::initializeGL(begin)"); - glbinding::Binding::initialize(global::windowDelegate.openGLProcedureAddress); + glbinding::Binding::initialize(global::windowDelegate->openGLProcedureAddress); //glbinding::Binding::useCurrentContext(); rendering::helper::initialize(); @@ -425,14 +427,14 @@ void OpenSpaceEngine::initializeGL() { using Verbosity = ghoul::systemcapabilities::SystemCapabilitiesComponent::Verbosity; Verbosity verbosity = ghoul::from_string( - global::configuration.logging.capabilitiesVerbosity - ); + global::configuration->logging.capabilitiesVerbosity + ); SysCap.logCapabilities(verbosity); // Check the required OpenGL versions of the registered modules ghoul::systemcapabilities::Version version = - global::moduleEngine.requiredOpenGLVersion(); + global::moduleEngine->requiredOpenGLVersion(); LINFO(fmt::format("Required OpenGL version: {}", ghoul::to_string(version))); if (OpenGLCap.openGLVersion() < version) { @@ -446,7 +448,7 @@ void OpenSpaceEngine::initializeGL() { { // Check the available OpenGL extensions against the required extensions using OCC = ghoul::systemcapabilities::OpenGLCapabilitiesComponent; - for (OpenSpaceModule* m : global::moduleEngine.modules()) { + for (OpenSpaceModule* m : global::moduleEngine->modules()) { for (const std::string& ext : m->requiredOpenGLExtensions()) { if (!SysCap.component().isExtensionSupported(ext)) { LFATAL(fmt::format( @@ -462,12 +464,14 @@ void OpenSpaceEngine::initializeGL() { loadFonts(); _loadingScreen = std::make_unique( - LoadingScreen::ShowMessage(global::configuration.loadingScreen.isShowingMessages), + LoadingScreen::ShowMessage( + global::configuration->loadingScreen.isShowingMessages + ), LoadingScreen::ShowNodeNames( - global::configuration.loadingScreen.isShowingNodeNames + global::configuration->loadingScreen.isShowingNodeNames ), LoadingScreen::ShowProgressbar( - global::configuration.loadingScreen.isShowingProgressbar + global::configuration->loadingScreen.isShowingProgressbar ) ); @@ -479,7 +483,7 @@ void OpenSpaceEngine::initializeGL() { LTRACE("OpenSpaceEngine::initializeGL::Console::initialize(begin)"); try { - global::luaConsole.initialize(); + global::luaConsole->initialize(); } catch (ghoul::RuntimeError& e) { LERROR("Error initializing Console with error:"); @@ -488,7 +492,7 @@ void OpenSpaceEngine::initializeGL() { LTRACE("OpenSpaceEngine::initializeGL::Console::initialize(end)"); LTRACE("OpenSpaceEngine::initializeGL::DebugContext(begin)"); - bool debugActive = global::configuration.openGLDebugContext.isActive; + bool debugActive = global::configuration->openGLDebugContext.isActive; // Debug output is not available before 4.3 const ghoul::systemcapabilities::Version minVersion = { 4, 3, 0 }; @@ -500,11 +504,11 @@ void OpenSpaceEngine::initializeGL() { if (debugActive) { using namespace ghoul::opengl::debug; - bool synchronous = global::configuration.openGLDebugContext.isSynchronous; + bool synchronous = global::configuration->openGLDebugContext.isSynchronous; setDebugOutput(DebugOutput(debugActive), SynchronousOutput(synchronous)); for (const configuration::Configuration::OpenGLDebugContext::IdentifierFilter&f : - global::configuration.openGLDebugContext.identifierFilters) + global::configuration->openGLDebugContext.identifierFilters) { setDebugMessageControl( ghoul::from_string(f.source), @@ -516,7 +520,7 @@ void OpenSpaceEngine::initializeGL() { } for (const std::string& sev : - global::configuration.openGLDebugContext.severityFilters) + global::configuration->openGLDebugContext.severityFilters) { setDebugMessageControl( Source::DontCare, @@ -559,7 +563,7 @@ void OpenSpaceEngine::initializeGL() { // the callback mask in glbinding is stateful for each context, and since // KeyLogEachOpenGLCall is more specific, we want it to be able to overwrite the // state from KeyCheckOpenGLState - if (global::configuration.isCheckingOpenGLState) { + if (global::configuration->isCheckingOpenGLState) { using namespace glbinding; // Infinite loop -- welcome to the danger zone @@ -612,9 +616,9 @@ void OpenSpaceEngine::initializeGL() { }); } - if (global::configuration.isLoggingOpenGLCalls) { + if (global::configuration->isLoggingOpenGLCalls) { using namespace ghoul::logging; - LogLevel lvl = ghoul::from_string(global::configuration.logging.level); + LogLevel lvl = ghoul::from_string(global::configuration->logging.level); if (lvl > LogLevel::Trace) { LWARNING( "Logging OpenGL calls is enabled, but the selected log level does " @@ -654,9 +658,9 @@ void OpenSpaceEngine::initializeGL() { } LDEBUG("Initializing Rendering Engine"); - global::renderEngine.initializeGL(); + global::renderEngine->initializeGL(); - global::moduleEngine.initializeGL(); + global::moduleEngine->initializeGL(); for (const std::function& func : global::callback::initializeGL) { @@ -679,11 +683,11 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) { LTRACE("OpenSpaceEngine::loadSingleAsset(begin)"); - global::windowDelegate.setBarrier(false); - global::windowDelegate.setSynchronization(false); + global::windowDelegate->setBarrier(false); + global::windowDelegate->setSynchronization(false); defer { - global::windowDelegate.setSynchronization(true); - global::windowDelegate.setBarrier(true); + global::windowDelegate->setSynchronization(true); + global::windowDelegate->setBarrier(true); }; if (assetPath.empty()) { @@ -692,19 +696,19 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) { if (_scene) { ZoneScopedN("Reset scene") - global::syncEngine.removeSyncables(global::timeManager.getSyncables()); + global::syncEngine->removeSyncables(global::timeManager->getSyncables()); if (_scene && _scene->camera()) { - global::syncEngine.removeSyncables(_scene->camera()->getSyncables()); + global::syncEngine->removeSyncables(_scene->camera()->getSyncables()); } - global::renderEngine.setScene(nullptr); - global::renderEngine.setCamera(nullptr); - global::navigationHandler.setCamera(nullptr); + global::renderEngine->setScene(nullptr); + global::renderEngine->setCamera(nullptr); + global::navigationHandler->setCamera(nullptr); _scene->clear(); - global::rootPropertyOwner.removePropertySubOwner(_scene.get()); + global::rootPropertyOwner->removePropertySubOwner(_scene.get()); } std::unique_ptr sceneInitializer; - if (global::configuration.useMultithreadedInitialization) { + if (global::configuration->useMultithreadedInitialization) { unsigned int nAvailableThreads = std::min( std::thread::hardware_concurrency() - 1, 4u @@ -717,21 +721,21 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) { } _scene = std::make_unique(std::move(sceneInitializer)); - global::renderEngine.setScene(_scene.get()); + global::renderEngine->setScene(_scene.get()); - global::rootPropertyOwner.addPropertySubOwner(_scene.get()); + global::rootPropertyOwner->addPropertySubOwner(_scene.get()); _scene->setCamera(std::make_unique()); Camera* camera = _scene->camera(); camera->setParent(_scene->root()); - global::renderEngine.setCamera(camera); - global::navigationHandler.setCamera(camera); + global::renderEngine->setCamera(camera); + global::navigationHandler->setCamera(camera); const SceneGraphNode* parent = camera->parent(); if (parent) { - global::navigationHandler.orbitalNavigator().setFocusNode(parent->identifier()); + global::navigationHandler->orbitalNavigator().setFocusNode(parent->identifier()); } else { - global::navigationHandler.orbitalNavigator().setFocusNode( + global::navigationHandler->orbitalNavigator().setFocusNode( _scene->root()->identifier() ); } @@ -775,7 +779,7 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) { bool loading = true; while (loading) { if (_shouldAbortLoading) { - global::windowDelegate.terminate(); + global::windowDelegate->terminate(); break; } _loadingScreen->render(); @@ -838,11 +842,11 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) { _loadingScreen = nullptr; - global::renderEngine.updateScene(); + global::renderEngine->updateScene(); - global::syncEngine.addSyncables(global::timeManager.getSyncables()); + global::syncEngine->addSyncables(global::timeManager->getSyncables()); if (_scene && _scene->camera()) { - global::syncEngine.addSyncables(_scene->camera()->getSyncables()); + global::syncEngine->addSyncables(_scene->camera()->getSyncables()); } #ifdef __APPLE__ @@ -865,19 +869,19 @@ void OpenSpaceEngine::deinitialize() { func(); } - global::navigationHandler.deinitialize(); + global::navigationHandler->deinitialize(); LTRACE("deinitialize(begin)"); - if (global::parallelPeer.status() != ParallelConnection::Status::Disconnected) { - global::parallelPeer.disconnect(); + if (global::parallelPeer->status() != ParallelConnection::Status::Disconnected) { + global::parallelPeer->disconnect(); } - if (global::renderEngine.scene() && global::renderEngine.scene()->camera()) { - global::syncEngine.removeSyncables( - global::renderEngine.scene()->camera()->getSyncables() + if (global::renderEngine->scene() && global::renderEngine->scene()->camera()) { + global::syncEngine->removeSyncables( + global::renderEngine->scene()->camera()->getSyncables() ); } - global::sessionRecording.deinitialize(); - global::versionChecker.cancel(); + global::sessionRecording->deinitialize(); + global::versionChecker->cancel(); _assetManager = nullptr; @@ -903,12 +907,12 @@ void OpenSpaceEngine::deinitializeGL() { LTRACE("OpenSpaceEngine::deinitializeGL(begin)"); // We want to render an image informing the user that we are shutting down - global::renderEngine.renderEndscreen(); - global::windowDelegate.swapBuffer(); + global::renderEngine->renderEndscreen(); + global::windowDelegate->swapBuffer(); - global::openSpaceEngine.assetManager().deinitialize(); - global::openSpaceEngine._scene = nullptr; - global::renderEngine.setScene(nullptr); + global::openSpaceEngine->assetManager().deinitialize(); + global::openSpaceEngine->_scene = nullptr; + global::renderEngine->setScene(nullptr); for (const std::function& func : global::callback::deinitializeGL) { func(); @@ -924,16 +928,16 @@ void OpenSpaceEngine::deinitializeGL() { } void OpenSpaceEngine::writeStaticDocumentation() { - std::string path = global::configuration.documentation.path; + std::string path = global::configuration->documentation.path; if (!path.empty()) { - DocEng.addHandlebarTemplates(global::scriptEngine.templatesToRegister()); + DocEng.addHandlebarTemplates(global::scriptEngine->templatesToRegister()); DocEng.addHandlebarTemplates(FactoryManager::ref().templatesToRegister()); DocEng.addHandlebarTemplates(DocEng.templatesToRegister()); _documentationJson += "{\"name\":\"Scripting\","; - _documentationJson += "\"identifier\":\"" + global::scriptEngine.jsonName(); - _documentationJson += "\",\"data\":" + global::scriptEngine.generateJson(); + _documentationJson += "\"identifier\":\"" + global::scriptEngine->jsonName(); + _documentationJson += "\",\"data\":" + global::scriptEngine->generateJson(); _documentationJson += "},"; _documentationJson += "{\"name\":\"Top Level\","; @@ -953,9 +957,9 @@ void OpenSpaceEngine::runGlobalCustomizationScripts() { LINFO("Running Global initialization scripts"); ghoul::lua::LuaState state; - global::scriptEngine.initializeLuaState(state); + global::scriptEngine->initializeLuaState(state); - for (const std::string& script : global::configuration.globalCustomizationScripts) { + for (const std::string& script : global::configuration->globalCustomizationScripts) { std::string s = absPath(script); if (FileSys.fileExists(s)) { try { @@ -972,10 +976,10 @@ void OpenSpaceEngine::runGlobalCustomizationScripts() { } void OpenSpaceEngine::loadFonts() { - global::fontManager.initialize(); + global::fontManager->initialize(); using T = std::string; - for (const std::pair& font : global::configuration.fonts) { + for (const std::pair& font : global::configuration->fonts) { std::string key = font.first; std::string fontName = absPath(font.second); @@ -985,7 +989,7 @@ void OpenSpaceEngine::loadFonts() { } LDEBUG(fmt::format("Registering font '{}' with key '{}'", fontName, key)); - bool success = global::fontManager.registerFontPath(key, fontName); + bool success = global::fontManager->registerFontPath(key, fontName); if (!success) { LERROR(fmt::format( @@ -1007,11 +1011,11 @@ void OpenSpaceEngine::writeSceneDocumentation() { // Write documentation to json files if config file supplies path for doc files - std::string path = global::configuration.documentation.path; + std::string path = global::configuration->documentation.path; if (!path.empty()) { std::future root = std::async( &properties::PropertyOwner::generateJson, - &global::rootPropertyOwner + global::rootPropertyOwner ); std::future scene = std::async( @@ -1023,9 +1027,9 @@ void OpenSpaceEngine::writeSceneDocumentation() { path = absPath(path) + "/"; _documentationJson += "{\"name\":\"Keybindings\",\"identifier\":\""; - _documentationJson += global::keybindingManager.jsonName() + "\","; + _documentationJson += global::keybindingManager->jsonName() + "\","; _documentationJson += "\"data\":"; - _documentationJson += global::keybindingManager.generateJson(); + _documentationJson += global::keybindingManager->generateJson(); _documentationJson += "},"; _documentationJson += "{\"name\":\"Scene License Information\","; _documentationJson += "\"identifier\":\"sceneLicense"; @@ -1042,12 +1046,12 @@ void OpenSpaceEngine::writeSceneDocumentation() { _documentationJson += "}"; //add templates for the jsons we just registered - DocEng.addHandlebarTemplates(global::keybindingManager.templatesToRegister()); + DocEng.addHandlebarTemplates(global::keybindingManager->templatesToRegister()); //TODO this is in efficaiant, here i am just instaning the class to get //at a member variable which is staticly defined. How do i just get that SceneLicenseWriter writer; DocEng.addHandlebarTemplates(writer.templatesToRegister()); - DocEng.addHandlebarTemplates(global::rootPropertyOwner.templatesToRegister()); + DocEng.addHandlebarTemplates(global::rootPropertyOwner->templatesToRegister()); //the static documentation shoudl be finished already //so now that we wrote the static and secene json files @@ -1068,57 +1072,57 @@ void OpenSpaceEngine::preSynchronization() { FileSys.triggerFilesystemEvents(); // Reset the temporary, frame-based storage - global::memoryManager.TemporaryMemory.reset(); + global::memoryManager->TemporaryMemory.reset(); if (_hasScheduledAssetLoading) { LINFO(fmt::format("Loading asset: {}", _scheduledAssetPathToLoad)); - global::profile.setIgnoreUpdates(true); + global::profile->setIgnoreUpdates(true); loadSingleAsset(_scheduledAssetPathToLoad); - global::profile.setIgnoreUpdates(false); - resetPropertyChangeFlagsOfSubowners(&global::rootPropertyOwner); + global::profile->setIgnoreUpdates(false); + resetPropertyChangeFlagsOfSubowners(global::rootPropertyOwner); _hasScheduledAssetLoading = false; _scheduledAssetPathToLoad.clear(); } if (_isFirstRenderingFirstFrame) { - global::windowDelegate.setSynchronization(false); + global::windowDelegate->setSynchronization(false); } - bool master = global::windowDelegate.isMaster(); + bool master = global::windowDelegate->isMaster(); - global::syncEngine.preSynchronization(SyncEngine::IsMaster(master)); + global::syncEngine->preSynchronization(SyncEngine::IsMaster(master)); if (master) { - double dt = global::windowDelegate.deltaTime(); + double dt = global::windowDelegate->deltaTime(); - if (global::sessionRecording.isSavingFramesDuringPlayback()) { - dt = global::sessionRecording.fixedDeltaTimeDuringFrameOutput(); + if (global::sessionRecording->isSavingFramesDuringPlayback()) { + dt = global::sessionRecording->fixedDeltaTimeDuringFrameOutput(); } - global::timeManager.preSynchronization(dt); + global::timeManager->preSynchronization(dt); using Iter = std::vector::const_iterator; - std::pair scheduledScripts = global::scriptScheduler.progressTo( - global::timeManager.time().j2000Seconds() + std::pair scheduledScripts = global::scriptScheduler->progressTo( + global::timeManager->time().j2000Seconds() ); for (Iter it = scheduledScripts.first; it != scheduledScripts.second; ++it) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( *it, scripting::ScriptEngine::RemoteScripting::Yes ); } - global::renderEngine.updateScene(); + global::renderEngine->updateScene(); if (_scene) { Camera* camera = _scene->camera(); if (camera) { - global::navigationHandler.updateCamera(dt); + global::navigationHandler->updateCamera(dt); camera->invalidateCache(); } } - global::sessionRecording.preSynchronization(); - global::parallelPeer.preSynchronization(); - global::interactionMonitor.updateActivityState(); + global::sessionRecording->preSynchronization(); + global::parallelPeer->preSynchronization(); + global::interactionMonitor->updateActivityState(); } for (const std::function& func : global::callback::preSync) { @@ -1134,24 +1138,24 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { TracyGpuZone("postSynchronizationPreDraw") LTRACE("OpenSpaceEngine::postSynchronizationPreDraw(begin)"); - bool master = global::windowDelegate.isMaster(); - global::syncEngine.postSynchronization(SyncEngine::IsMaster(master)); + bool master = global::windowDelegate->isMaster(); + global::syncEngine->postSynchronization(SyncEngine::IsMaster(master)); // This probably doesn't have to be done here every frame, but doing it earlier gives // weird results when using side_by_side stereo --- abock using FR = ghoul::fontrendering::FontRenderer; - FR::defaultRenderer().setFramebufferSize(global::renderEngine.fontResolution()); + FR::defaultRenderer().setFramebufferSize(global::renderEngine->fontResolution()); FR::defaultProjectionRenderer().setFramebufferSize( - global::renderEngine.renderingResolution() + global::renderEngine->renderingResolution() ); if (_shutdown.inShutdown) { if (_shutdown.timer <= 0.f) { - global::windowDelegate.terminate(); + global::windowDelegate->terminate(); return; } - _shutdown.timer -= static_cast(global::windowDelegate.averageDeltaTime()); + _shutdown.timer -= static_cast(global::windowDelegate->averageDeltaTime()); } @@ -1167,10 +1171,10 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { ); } - global::renderEngine.updateScene(); - global::renderEngine.updateRenderer(); - global::renderEngine.updateScreenSpaceRenderables(); - global::renderEngine.updateShaderPrograms(); + global::renderEngine->updateScene(); + global::renderEngine->updateRenderer(); + global::renderEngine->updateScreenSpaceRenderables(); + global::renderEngine->updateShaderPrograms(); if (!master) { _scene->camera()->invalidateCache(); @@ -1212,15 +1216,15 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& view LTRACE("OpenSpaceEngine::render(begin)"); const bool isGuiWindow = - global::windowDelegate.hasGuiWindow() ? - global::windowDelegate.isGuiWindow() : + global::windowDelegate->hasGuiWindow() ? + global::windowDelegate->isGuiWindow() : true; if (isGuiWindow) { - global::luaConsole.update(); + global::luaConsole->update(); } - global::renderEngine.render(sceneMatrix, viewMatrix, projectionMatrix); + global::renderEngine->render(sceneMatrix, viewMatrix, projectionMatrix); for (const std::function& func : global::callback::render) { ZoneScopedN("[Module] render") @@ -1237,14 +1241,14 @@ void OpenSpaceEngine::drawOverlays() { LTRACE("OpenSpaceEngine::drawOverlays(begin)"); const bool isGuiWindow = - global::windowDelegate.hasGuiWindow() ? - global::windowDelegate.isGuiWindow() : + global::windowDelegate->hasGuiWindow() ? + global::windowDelegate->isGuiWindow() : true; if (isGuiWindow) { - global::renderEngine.renderOverlays(_shutdown); - global::luaConsole.render(); - global::sessionRecording.render(); + global::renderEngine->renderOverlays(_shutdown); + global::luaConsole->render(); + global::sessionRecording->render(); } for (const std::function& func : global::callback::draw2D) { @@ -1261,7 +1265,7 @@ void OpenSpaceEngine::postDraw() { TracyGpuZone("postDraw") LTRACE("OpenSpaceEngine::postDraw(begin)"); - global::renderEngine.postDraw(); + global::renderEngine->postDraw(); for (const std::function& func : global::callback::postDraw) { ZoneScopedN("[Module] postDraw") @@ -1270,12 +1274,12 @@ void OpenSpaceEngine::postDraw() { } if (_isFirstRenderingFirstFrame) { - global::windowDelegate.setSynchronization(true); + global::windowDelegate->setSynchronization(true); resetPropertyChangeFlags(); _isFirstRenderingFirstFrame = false; } - global::memoryManager.PersistentMemory.housekeeping(); + global::memoryManager->PersistentMemory.housekeeping(); LTRACE("OpenSpaceEngine::postDraw(end)"); } @@ -1284,7 +1288,7 @@ void OpenSpaceEngine::resetPropertyChangeFlags() { ZoneScoped std::vector nodes = - global::renderEngine.scene()->allSceneGraphNodes(); + global::renderEngine->scene()->allSceneGraphNodes(); for (SceneGraphNode* n : nodes) { resetPropertyChangeFlagsOfSubowners(n); } @@ -1320,16 +1324,16 @@ void OpenSpaceEngine::keyboardCallback(Key key, KeyModifier mod, KeyAction actio } } - if (!global::configuration.isConsoleDisabled) { - bool isConsoleConsumed = global::luaConsole.keyboardCallback(key, mod, action); + if (!global::configuration->isConsoleDisabled) { + bool isConsoleConsumed = global::luaConsole->keyboardCallback(key, mod, action); if (isConsoleConsumed) { return; } } - global::navigationHandler.keyboardCallback(key, mod, action); - global::keybindingManager.keyboardCallback(key, mod, action); - global::interactionMonitor.markInteraction(); + global::navigationHandler->keyboardCallback(key, mod, action); + global::keybindingManager->keyboardCallback(key, mod, action); + global::interactionMonitor->markInteraction(); } void OpenSpaceEngine::charCallback(unsigned int codepoint, KeyModifier modifier) { @@ -1343,8 +1347,8 @@ void OpenSpaceEngine::charCallback(unsigned int codepoint, KeyModifier modifier) } } - global::luaConsole.charCallback(codepoint, modifier); - global::interactionMonitor.markInteraction(); + global::luaConsole->charCallback(codepoint, modifier); + global::interactionMonitor->markInteraction(); } void OpenSpaceEngine::mouseButtonCallback(MouseButton button, @@ -1372,14 +1376,14 @@ void OpenSpaceEngine::mouseButtonCallback(MouseButton button, // Check if the user clicked on one of the 'buttons' the RenderEngine is drawing if (action == MouseAction::Press) { - bool isConsumed = global::renderEngine.mouseActivationCallback(_mousePosition); + bool isConsumed = global::renderEngine->mouseActivationCallback(_mousePosition); if (isConsumed) { return; } } - global::navigationHandler.mouseButtonCallback(button, action); - global::interactionMonitor.markInteraction(); + global::navigationHandler->mouseButtonCallback(button, action); + global::interactionMonitor->markInteraction(); } void OpenSpaceEngine::mousePositionCallback(double x, double y) { @@ -1390,8 +1394,8 @@ void OpenSpaceEngine::mousePositionCallback(double x, double y) { func(x, y); } - global::navigationHandler.mousePositionCallback(x, y); - global::interactionMonitor.markInteraction(); + global::navigationHandler->mousePositionCallback(x, y); + global::interactionMonitor->markInteraction(); _mousePosition = glm::vec2(static_cast(x), static_cast(y)); } @@ -1407,8 +1411,8 @@ void OpenSpaceEngine::mouseScrollWheelCallback(double posX, double posY) { } } - global::navigationHandler.mouseScrollWheelCallback(posY); - global::interactionMonitor.markInteraction(); + global::navigationHandler->mouseScrollWheelCallback(posY); + global::interactionMonitor->markInteraction(); } void OpenSpaceEngine::touchDetectionCallback(TouchInput input) { @@ -1448,14 +1452,14 @@ void OpenSpaceEngine::touchExitCallback(TouchInput input) { std::vector OpenSpaceEngine::encode() { ZoneScoped - std::vector buffer = global::syncEngine.encodeSyncables(); + std::vector buffer = global::syncEngine->encodeSyncables(); return buffer; } void OpenSpaceEngine::decode(std::vector data) { ZoneScoped - global::syncEngine.decodeSyncables(std::move(data)); + global::syncEngine->decodeSyncables(std::move(data)); } void OpenSpaceEngine::toggleShutdownMode() { diff --git a/src/engine/openspaceengine_lua.inl b/src/engine/openspaceengine_lua.inl index db0a9a70fa..f92dad961b 100644 --- a/src/engine/openspaceengine_lua.inl +++ b/src/engine/openspaceengine_lua.inl @@ -39,7 +39,7 @@ namespace openspace::luascriptfunctions { int toggleShutdown(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::toggleShutdown"); - global::openSpaceEngine.toggleShutdownMode(); + global::openSpaceEngine->toggleShutdownMode(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -53,8 +53,8 @@ int toggleShutdown(lua_State* L) { int writeDocumentation(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::writeDocumentation"); - global::openSpaceEngine.writeStaticDocumentation(); - global::openSpaceEngine.writeSceneDocumentation(); + global::openSpaceEngine->writeStaticDocumentation(); + global::openSpaceEngine->writeSceneDocumentation(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -132,7 +132,7 @@ int addVirtualProperty(lua_State* L) { } lua_settop(L, 0); - global::virtualPropertyManager.addProperty(std::move(prop)); + global::virtualPropertyManager->addProperty(std::move(prop)); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -147,9 +147,9 @@ int removeVirtualProperty(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::removeVirtualProperty"); const std::string& name = ghoul::lua::value(L, 1); - properties::Property* p = global::virtualPropertyManager.property(name); + properties::Property* p = global::virtualPropertyManager->property(name); if (p) { - global::virtualPropertyManager.removeProperty(p); + global::virtualPropertyManager->removeProperty(p); } else { LWARNINGC( @@ -172,9 +172,9 @@ int removeAllVirtualProperties(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::removeAllVirtualProperties"); const std::vector& ps = - global::virtualPropertyManager.properties(); + global::virtualPropertyManager->properties(); for (properties::Property* p : ps) { - global::virtualPropertyManager.removeProperty(p); + global::virtualPropertyManager->removeProperty(p); delete p; } @@ -194,7 +194,7 @@ int addTag(lua_State* L) { std::string tag = ghoul::lua::value(L, 2); lua_settop(L, 0); - SceneGraphNode* node = global::renderEngine.scene()->sceneGraphNode(uri); + SceneGraphNode* node = global::renderEngine->scene()->sceneGraphNode(uri); if (!node) { return ghoul::lua::luaError( L, @@ -220,7 +220,7 @@ int removeTag(lua_State* L) { const std::string& tag = ghoul::lua::value(L, 2); lua_settop(L, 0); - SceneGraphNode* node = global::renderEngine.scene()->sceneGraphNode(uri); + SceneGraphNode* node = global::renderEngine->scene()->sceneGraphNode(uri); if (!node) { return ghoul::lua::luaError( L, @@ -248,7 +248,7 @@ int downloadFile(lua_State* L) { LINFOC("OpenSpaceEngine", fmt::format("Downloading file from {}", uri)); std::shared_ptr future = - global::downloadManager.downloadFile( + global::downloadManager->downloadFile( uri, savePath, DownloadManager::OverrideFile::Yes, @@ -268,7 +268,7 @@ int downloadFile(lua_State* L) { int isMaster(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::isMaster"); - ghoul::lua::push(L, global::windowDelegate.isMaster()); + ghoul::lua::push(L, global::windowDelegate->isMaster()); return 1; } diff --git a/src/interaction/externinteraction.cpp b/src/interaction/externinteraction.cpp index 7f40dae10e..bb4641017b 100644 --- a/src/interaction/externinteraction.cpp +++ b/src/interaction/externinteraction.cpp @@ -82,7 +82,7 @@ void ExternInteraction::cameraInteraction(datamessagestructures::CameraKeyframe pose.scale = std::move(kf._scale); pose.followFocusNodeRotation = std::move(kf._followNodeRotation); - global::navigationHandler.keyframeNavigator().addKeyframe(kf._timestamp, pose); + global::navigationHandler->keyframeNavigator().addKeyframe(kf._timestamp, pose); } void ExternInteraction::timeInteraction(datamessagestructures::TimeKeyframe kf) { @@ -91,18 +91,18 @@ void ExternInteraction::timeInteraction(datamessagestructures::TimeKeyframe kf) timeKfData.pause = std::move(kf._paused); timeKfData.jump = std::move(kf._requiresTimeJump); - global::timeManager.addKeyframe(kf._timestamp, timeKfData); + global::timeManager->addKeyframe(kf._timestamp, timeKfData); } void ExternInteraction::scriptInteraction(datamessagestructures::ScriptMessage sm) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( std::move(sm._script), scripting::ScriptEngine::RemoteScripting::No ); } datamessagestructures::CameraKeyframe ExternInteraction::generateCameraKeyframe() { - interaction::NavigationHandler& navHandler = global::navigationHandler; + interaction::NavigationHandler& navHandler = *global::navigationHandler; datamessagestructures::CameraKeyframe kf; const SceneGraphNode* focusNode = navHandler.orbitalNavigator().anchorNode(); @@ -126,21 +126,21 @@ datamessagestructures::CameraKeyframe ExternInteraction::generateCameraKeyframe( kf._scale = navHandler.camera()->scaling(); // Timestamp as current runtime of OpenSpace instance - kf._timestamp = global::windowDelegate.applicationTime(); + kf._timestamp = global::windowDelegate->applicationTime(); return kf; } datamessagestructures::TimeKeyframe ExternInteraction::generateTimeKeyframe() { datamessagestructures::TimeKeyframe kf; - const Time& time = global::timeManager.time(); + const Time& time = global::timeManager->time(); - kf._dt = global::timeManager.deltaTime(); - kf._paused = global::timeManager.isPaused(); + kf._dt = global::timeManager->deltaTime(); + kf._paused = global::timeManager->isPaused(); kf._time = time.j2000Seconds(); // Timestamp as current runtime of OpenSpace instance - kf._timestamp = global::windowDelegate.applicationTime(); + kf._timestamp = global::windowDelegate->applicationTime(); return kf; } @@ -150,7 +150,7 @@ datamessagestructures::ScriptMessage ExternInteraction::generateScriptMessage( datamessagestructures::ScriptMessage sm; sm._script = std::move(script); // Timestamp as current runtime of OpenSpace instance - sm._timestamp = global::windowDelegate.applicationTime(); + sm._timestamp = global::windowDelegate->applicationTime(); return sm; } diff --git a/src/interaction/inputstate.cpp b/src/interaction/inputstate.cpp index 3eea2e6716..c603937722 100644 --- a/src/interaction/inputstate.cpp +++ b/src/interaction/inputstate.cpp @@ -108,31 +108,31 @@ bool InputState::isMouseButtonPressed(MouseButton mouseButton) const { } float InputState::joystickAxis(int i) const { - return global::joystickInputStates.axis(i); + return global::joystickInputStates->axis(i); } bool InputState::joystickButton(int i) const { - return global::joystickInputStates.button(i, JoystickAction::Press); + return global::joystickInputStates->button(i, JoystickAction::Press); } float InputState::websocketAxis(int i) const { - return global::websocketInputStates.axis(i); + return global::websocketInputStates->axis(i); } bool InputState::websocketButton(int i) const { - return global::websocketInputStates.button(i, WebsocketAction::Press); + return global::websocketInputStates->button(i, WebsocketAction::Press); } void InputState::resetWebsockets() { using K = size_t; using V = WebsocketInputState*; - for (const std::pair& p : global::websocketInputStates) { + for (const std::pair& p : *global::websocketInputStates) { p.second->isConnected = false; } } bool InputState::hasWebsocketStates() const { - return !global::websocketInputStates.empty(); + return !global::websocketInputStates->empty(); } } // namespace openspace::interaction diff --git a/src/interaction/interactionmonitor.cpp b/src/interaction/interactionmonitor.cpp index 78333fe620..2b88c7bcc0 100644 --- a/src/interaction/interactionmonitor.cpp +++ b/src/interaction/interactionmonitor.cpp @@ -65,7 +65,7 @@ void InteractionMonitor::setIdleTime(float time) { } void InteractionMonitor::updateActivityState() { - const double currentApplicationTime = global::windowDelegate.applicationTime(); + const double currentApplicationTime = global::windowDelegate->applicationTime(); const double timeDiff = currentApplicationTime - _lastInteractionTime; if (timeDiff >= _idleTime && _isInActiveState) { @@ -74,7 +74,7 @@ void InteractionMonitor::updateActivityState() { } void InteractionMonitor::markInteraction() { - _lastInteractionTime = global::windowDelegate.applicationTime(); + _lastInteractionTime = global::windowDelegate->applicationTime(); _isInActiveState = true; } diff --git a/src/interaction/joystickcamerastates.cpp b/src/interaction/joystickcamerastates.cpp index bb0a73514d..6f38580fdd 100644 --- a/src/interaction/joystickcamerastates.cpp +++ b/src/interaction/joystickcamerastates.cpp @@ -154,10 +154,10 @@ void JoystickCameraStates::updateStateFromInput(const InputState& inputState, for (int i = 0; i < JoystickInputState::MaxButtons; ++i) { auto itRange = _buttonMapping.equal_range(i); for (auto it = itRange.first; it != itRange.second; ++it) { - bool active = global::joystickInputStates.button(i, it->second.action); + bool active = global::joystickInputStates->button(i, it->second.action); if (active) { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( it->second.command, scripting::ScriptEngine::RemoteScripting(it->second.synchronization) ); diff --git a/src/interaction/keybindingmanager.cpp b/src/interaction/keybindingmanager.cpp index d74b78efc8..aabe3c3c0c 100644 --- a/src/interaction/keybindingmanager.cpp +++ b/src/interaction/keybindingmanager.cpp @@ -53,7 +53,7 @@ void KeybindingManager::keyboardCallback(Key key, KeyModifier modifier, KeyActio for (auto it = ret.first; it != ret.second; ++it) { using RS = scripting::ScriptEngine::RemoteScripting; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( it->second.command, it->second.synchronization ? RS::Yes : RS::No ); diff --git a/src/interaction/keybindingmanager_lua.inl b/src/interaction/keybindingmanager_lua.inl index 8f01b04d58..9b4db7fd33 100644 --- a/src/interaction/keybindingmanager_lua.inl +++ b/src/interaction/keybindingmanager_lua.inl @@ -60,7 +60,7 @@ int bindKey(lua_State* L) { std::string name = (nArguments >= 4) ? ghoul::lua::value(L, 4) : ""; std::string guiPath = (nArguments == 5) ? ghoul::lua::value(L, 5) : ""; - global::keybindingManager.bindKey( + global::keybindingManager->bindKey( iKey.key, iKey.modifier, std::move(command), @@ -107,7 +107,7 @@ int bindKeyLocal(lua_State* L) { ghoul::lua::value(L, 5) : ""; - global::keybindingManager.bindKeyLocal( + global::keybindingManager->bindKeyLocal( iKey.key, iKey.modifier, std::move(command), @@ -139,7 +139,7 @@ int getKeyBindings(lua_State* L) { using K = KeyWithModifier; using V = interaction::KeybindingManager::KeyInformation; - const std::vector>& info = global::keybindingManager.keyBinding(key); + const std::vector>& info = global::keybindingManager->keyBinding(key); lua_createtable(L, static_cast(info.size()), 0); int i = 1; @@ -174,7 +174,7 @@ int clearKey(lua_State* L) { if (t == LUA_TSTRING) { // The user provided a single key const std::string& key = ghoul::lua::value(L, 1); - global::keybindingManager.removeKeyBinding(key); + global::keybindingManager->removeKeyBinding(key); } else { // The user provided a list of keys @@ -182,7 +182,7 @@ int clearKey(lua_State* L) { ghoul::lua::luaDictionaryFromState(L, d); for (size_t i = 1; i <= d.size(); ++i) { const std::string& k = d.value(std::to_string(i)); - global::keybindingManager.removeKeyBinding(k); + global::keybindingManager->removeKeyBinding(k); } lua_pop(L, 1); } @@ -200,7 +200,7 @@ int clearKey(lua_State* L) { int clearKeys(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clearKeys"); - global::keybindingManager.resetKeyBindings(); + global::keybindingManager->resetKeyBindings(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; diff --git a/src/interaction/keyframenavigator.cpp b/src/interaction/keyframenavigator.cpp index ba9c2a7e4b..c7de51ac17 100644 --- a/src/interaction/keyframenavigator.cpp +++ b/src/interaction/keyframenavigator.cpp @@ -189,13 +189,13 @@ bool KeyframeNavigator::updateCamera(Camera* camera, const CameraPose prevPose, double KeyframeNavigator::currentTime() const { if (_timeframeMode == KeyframeTimeRef::Relative_recordedStart) { - return (global::windowDelegate.applicationTime() - _referenceTimestamp); + return (global::windowDelegate->applicationTime() - _referenceTimestamp); } else if (_timeframeMode == KeyframeTimeRef::Absolute_simTimeJ2000) { - return global::timeManager.time().j2000Seconds(); + return global::timeManager->time().j2000Seconds(); } else { - return global::windowDelegate.applicationTime(); + return global::windowDelegate->applicationTime(); } } diff --git a/src/interaction/navigationhandler.cpp b/src/interaction/navigationhandler.cpp index e8d6094b0d..548a0b9c3b 100644 --- a/src/interaction/navigationhandler.cpp +++ b/src/interaction/navigationhandler.cpp @@ -162,11 +162,11 @@ NavigationHandler::~NavigationHandler() {} // NOLINT void NavigationHandler::initialize() { ZoneScoped - global::parallelPeer.connectionEvent().subscribe( + global::parallelPeer->connectionEvent().subscribe( "NavigationHandler", "statusChanged", [this]() { - _useKeyFrameInteraction = (global::parallelPeer.status() == + _useKeyFrameInteraction = (global::parallelPeer->status() == ParallelConnection::Status::ClientWithHost); } ); @@ -175,7 +175,7 @@ void NavigationHandler::initialize() { void NavigationHandler::deinitialize() { ZoneScoped - global::parallelPeer.connectionEvent().unsubscribe("NavigationHandler"); + global::parallelPeer->connectionEvent().unsubscribe("NavigationHandler"); } void NavigationHandler::setFocusNode(SceneGraphNode* node) { diff --git a/src/interaction/navigationhandler_lua.inl b/src/interaction/navigationhandler_lua.inl index f29fdb7a11..4ccb59d75c 100644 --- a/src/interaction/navigationhandler_lua.inl +++ b/src/interaction/navigationhandler_lua.inl @@ -40,7 +40,7 @@ int loadNavigationState(lua_State* L) { return ghoul::lua::luaError(L, "filepath string is empty"); } - global::navigationHandler.loadNavigationState(cameraStateFilePath); + global::navigationHandler->loadNavigationState(cameraStateFilePath); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -65,10 +65,10 @@ int getNavigationState(lua_State* L) { lua_settop(L, 0); return 0; } - state = global::navigationHandler.navigationState(*referenceFrame); + state = global::navigationHandler->navigationState(*referenceFrame); } else { - state = global::navigationHandler.navigationState(); + state = global::navigationHandler->navigationState(); } lua_settop(L, 0); @@ -135,7 +135,7 @@ int setNavigationState(lua_State* L) { ); } - global::navigationHandler.setNavigationStateNextFrame(navigationStateDictionary); + global::navigationHandler->setNavigationStateNextFrame(navigationStateDictionary); // @CLEANUP: When luaDictionaryFromState doesn't leak space anymore, remove the next // line ---abock(2018-02-15) @@ -162,7 +162,7 @@ int saveNavigationState(lua_State* L) { return ghoul::lua::luaError(L, "filepath string is empty"); } - global::navigationHandler.saveNavigationState(cameraStateFilePath, referenceFrame); + global::navigationHandler->saveNavigationState(cameraStateFilePath, referenceFrame); lua_settop(L, 0); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -172,7 +172,7 @@ int saveNavigationState(lua_State* L) { int retargetAnchor(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::retargetAnchor"); - global::navigationHandler.orbitalNavigator().startRetargetAnchor(); + global::navigationHandler->orbitalNavigator().startRetargetAnchor(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -181,7 +181,7 @@ int retargetAnchor(lua_State* L) { int retargetAim(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::retargetAim"); - global::navigationHandler.orbitalNavigator().startRetargetAim(); + global::navigationHandler->orbitalNavigator().startRetargetAim(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -200,7 +200,7 @@ int bindJoystickAxis(lua_State* L) { const bool shouldInvert = n > 2 ? ghoul::lua::value(L, 3) : false; const bool shouldNormalize = n > 3 ? ghoul::lua::value(L, 4) : false; - global::navigationHandler.setJoystickAxisMapping( + global::navigationHandler->setJoystickAxisMapping( axis, ghoul::from_string(axisType), interaction::JoystickCameraStates::AxisInvert(shouldInvert), @@ -218,7 +218,7 @@ int joystickAxis(lua_State* L) { const int axis = ghoul::lua::value(L, 1); using AI = interaction::JoystickCameraStates::AxisInformation; - AI info = global::navigationHandler.joystickAxisMapping(axis); + AI info = global::navigationHandler->joystickAxisMapping(axis); lua_settop(L, 0); const bool invert = info.invert; @@ -236,7 +236,7 @@ int setJoystickAxisDeadzone(lua_State* L) { const float deadzone = ghoul::lua::value(L, 2); lua_settop(L, 0); - global::navigationHandler.setJoystickAxisDeadzone(axis, deadzone); + global::navigationHandler->setJoystickAxisDeadzone(axis, deadzone); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -247,7 +247,7 @@ int joystickAxisDeadzone(lua_State* L) { const int axis = ghoul::lua::value(L, 1, ghoul::lua::PopValue::Yes); - const float deadzone = global::navigationHandler.joystickAxisDeadzone(axis); + const float deadzone = global::navigationHandler->joystickAxisDeadzone(axis); ghoul::lua::push(L, deadzone); ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); @@ -274,7 +274,7 @@ int bindJoystickButton(lua_State* L) { const bool isRemote = n == 5 ? ghoul::lua::value(L, 5) : true; lua_settop(L, 0); - global::navigationHandler.bindJoystickButtonCommand( + global::navigationHandler->bindJoystickButtonCommand( button, std::move(command), action, @@ -291,7 +291,7 @@ int clearJoystickButton(lua_State* L) { const int button = ghoul::lua::value(L, 1, ghoul::lua::PopValue::Yes); - global::navigationHandler.clearJoystickButtonCommand(button); + global::navigationHandler->clearJoystickButtonCommand(button); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -303,7 +303,7 @@ int joystickButton(lua_State* L) { const int button = ghoul::lua::value(L, 1, ghoul::lua::PopValue::Yes); const std::vector& cmds = - global::navigationHandler.joystickButtonCommand(button); + global::navigationHandler->joystickButtonCommand(button); std::string cmd = std::accumulate( cmds.begin(), @@ -325,7 +325,7 @@ int addGlobalRotation(lua_State* L) { const double v1 = ghoul::lua::value(L, 1, ghoul::lua::PopValue::No); const double v2 = ghoul::lua::value(L, 2, ghoul::lua::PopValue::No); - global::navigationHandler.orbitalNavigator().scriptStates().addGlobalRotation( + global::navigationHandler->orbitalNavigator().scriptStates().addGlobalRotation( glm::dvec2(v1, v2) ); @@ -339,7 +339,7 @@ int addLocalRotation(lua_State* L) { const double v1 = ghoul::lua::value(L, 1, ghoul::lua::PopValue::No); const double v2 = ghoul::lua::value(L, 2, ghoul::lua::PopValue::No); - global::navigationHandler.orbitalNavigator().scriptStates().addLocalRotation( + global::navigationHandler->orbitalNavigator().scriptStates().addLocalRotation( glm::dvec2(v1, v2) ); @@ -353,7 +353,7 @@ int addTruckMovement(lua_State* L) { const double v1 = ghoul::lua::value(L, 1, ghoul::lua::PopValue::No); const double v2 = ghoul::lua::value(L, 2, ghoul::lua::PopValue::No); - global::navigationHandler.orbitalNavigator().scriptStates().addTruckMovement( + global::navigationHandler->orbitalNavigator().scriptStates().addTruckMovement( glm::dvec2(v1, v2) ); @@ -367,7 +367,7 @@ int addLocalRoll(lua_State* L) { const double v1 = ghoul::lua::value(L, 1, ghoul::lua::PopValue::No); const double v2 = ghoul::lua::value(L, 2, ghoul::lua::PopValue::No); - global::navigationHandler.orbitalNavigator().scriptStates().addLocalRoll( + global::navigationHandler->orbitalNavigator().scriptStates().addLocalRoll( glm::dvec2(v1, v2) ); @@ -381,7 +381,7 @@ int addGlobalRoll(lua_State* L) { const double v1 = ghoul::lua::value(L, 1, ghoul::lua::PopValue::No); const double v2 = ghoul::lua::value(L, 2, ghoul::lua::PopValue::No); - global::navigationHandler.orbitalNavigator().scriptStates().addGlobalRoll( + global::navigationHandler->orbitalNavigator().scriptStates().addGlobalRoll( glm::dvec2(v1, v2) ); diff --git a/src/interaction/sessionrecording.cpp b/src/interaction/sessionrecording.cpp index 56a5f3a462..9425204fe9 100644 --- a/src/interaction/sessionrecording.cpp +++ b/src/interaction/sessionrecording.cpp @@ -180,10 +180,10 @@ bool SessionRecording::startRecording(const std::string& filename) { } _recordFile << '\n'; - _timestampRecordStarted = global::windowDelegate.applicationTime(); + _timestampRecordStarted = global::windowDelegate->applicationTime(); //Record the current delta time so this is preserved in recording - double currentDeltaTime = global::timeManager.deltaTime(); + double currentDeltaTime = global::timeManager->deltaTime(); std::string scriptCommandForInitializingDeltaTime = "openspace.time.setDeltaTime(" + std::to_string(currentDeltaTime) + ")"; saveScriptKeyframe(scriptCommandForInitializingDeltaTime); @@ -277,9 +277,9 @@ bool SessionRecording::startPlayback(const std::string& filename, return false; } //Set time reference mode - double now = global::windowDelegate.applicationTime(); + double now = global::windowDelegate->applicationTime(); _timestampPlaybackStarted_application = now; - _timestampPlaybackStarted_simulation = global::timeManager.time().j2000Seconds(); + _timestampPlaybackStarted_simulation = global::timeManager->time().j2000Seconds(); _timestampApplicationStarted_simulation = _timestampPlaybackStarted_simulation - now; _playbackTimeReferenceMode = timeMode; @@ -290,8 +290,8 @@ bool SessionRecording::startPlayback(const std::string& filename, _playbackActive_time = true; } - global::navigationHandler.keyframeNavigator().setTimeReferenceMode(timeMode, now); - global::scriptScheduler.setTimeReferenceMode(timeMode); + global::navigationHandler->keyframeNavigator().setTimeReferenceMode(timeMode, now); + global::scriptScheduler->setTimeReferenceMode(timeMode); _setSimulationTimeWithNextCameraKeyframe = forceSimTimeAtStart; if (!playbackAddEntriesToTimeline()) { @@ -309,9 +309,9 @@ bool SessionRecording::startPlayback(const std::string& filename, _keyframesTime.size(), _keyframesScript.size(), (forceSimTimeAtStart ? 1 : 0) )); - global::navigationHandler.triggerPlaybackStart(); - global::scriptScheduler.triggerPlaybackStart(); - global::timeManager.triggerPlaybackStart(); + global::navigationHandler->triggerPlaybackStart(); + global::scriptScheduler->triggerPlaybackStart(); + global::timeManager->triggerPlaybackStart(); _state = SessionState::Playback; return true; @@ -375,20 +375,20 @@ void SessionRecording::stopPlayback() { } void SessionRecording::cleanUpPlayback() { - global::navigationHandler.stopPlayback(); - global::timeManager.stopPlayback(); + global::navigationHandler->stopPlayback(); + global::timeManager->stopPlayback(); - Camera* camera = global::navigationHandler.camera(); + Camera* camera = global::navigationHandler->camera(); ghoul_assert(camera != nullptr, "Camera must not be nullptr"); Scene* scene = camera->parent()->scene(); if (!_timeline.empty()) { unsigned int p = _timeline[_idxTimeline_cameraPtrPrev].idxIntoKeyframeTypeArray; - const SceneGraphNode* node = scene->sceneGraphNode(_keyframesCamera[p].focusNode); - if (node) { - global::navigationHandler.orbitalNavigator().setFocusNode(node->identifier()); + const SceneGraphNode* n = scene->sceneGraphNode(_keyframesCamera[p].focusNode); + if (n) { + global::navigationHandler->orbitalNavigator().setFocusNode(n->identifier()); } } - global::scriptScheduler.stopPlayback(); + global::scriptScheduler->stopPlayback(); _playbackFile.close(); @@ -486,7 +486,7 @@ void SessionRecording::saveCameraKeyframe() { return; } - const SceneGraphNode* an = global::navigationHandler.orbitalNavigator().anchorNode(); + const SceneGraphNode* an = global::navigationHandler->orbitalNavigator().anchorNode(); if (!an) { return; } @@ -498,7 +498,7 @@ void SessionRecording::saveCameraKeyframe() { Timestamps times = { kf._timestamp, kf._timestamp - _timestampRecordStarted, - global::timeManager.time().j2000Seconds() + global::timeManager->time().j2000Seconds() }; if (_recordingDataMode == DataMode::Binary) { saveCameraKeyframeBinary(times, kf, _keyframeBuffer, _recordFile); @@ -565,7 +565,7 @@ void SessionRecording::saveTimeKeyframe() { Timestamps times = { kf._timestamp, kf._timestamp - _timestampRecordStarted, - global::timeManager.time().j2000Seconds() + global::timeManager->time().j2000Seconds() }; if (_recordingDataMode == DataMode::Binary) { saveTimeKeyframeBinary(times, kf, _keyframeBuffer, _recordFile); @@ -608,7 +608,7 @@ void SessionRecording::saveScriptKeyframe(std::string scriptToSave) { Timestamps times = { sm._timestamp, sm._timestamp - _timestampRecordStarted, - global::timeManager.time().j2000Seconds() + global::timeManager->time().j2000Seconds() }; if (_recordingDataMode == DataMode::Binary) { @@ -682,9 +682,9 @@ void SessionRecording::render() { constexpr const char* FontName = "Mono"; constexpr const float FontSizeFrameinfo = 32.f; std::shared_ptr font = - global::fontManager.font(FontName, FontSizeFrameinfo); + global::fontManager->font(FontName, FontSizeFrameinfo); - glm::vec2 res = global::renderEngine.fontResolution(); + glm::vec2 res = global::renderEngine->fontResolution(); glm::vec2 penPosition = glm::vec2( res.x / 2 - 150.f, res.y / 4 @@ -842,14 +842,14 @@ double SessionRecording::currentTime() const { return _saveRenderingCurrentRecordedTime; } else if (_playbackTimeReferenceMode == KeyframeTimeRef::Relative_recordedStart) { - return (global::windowDelegate.applicationTime() - + return (global::windowDelegate->applicationTime() - _timestampPlaybackStarted_application); } else if (_playbackTimeReferenceMode == KeyframeTimeRef::Absolute_simTimeJ2000) { - return global::timeManager.time().j2000Seconds(); + return global::timeManager->time().j2000Seconds(); } else { - return global::windowDelegate.applicationTime(); + return global::windowDelegate->applicationTime(); } } @@ -857,7 +857,7 @@ double SessionRecording::fixedDeltaTimeDuringFrameOutput() const { // Check if renderable in focus is still resolving tile loading // do not adjust time while we are doing this const SceneGraphNode* focusNode = - global::navigationHandler.orbitalNavigator().anchorNode(); + global::navigationHandler->orbitalNavigator().anchorNode(); const Renderable* focusRenderable = focusNode->renderable(); if (!focusRenderable || focusRenderable->renderedWithDesiredData()) { return _saveRenderingDeltaTime; @@ -879,7 +879,7 @@ bool SessionRecording::playbackCamera() { } if (_setSimulationTimeWithNextCameraKeyframe) { - global::timeManager.setTimeNextFrame(Time(times.timeSim)); + global::timeManager->setTimeNextFrame(Time(times.timeSim)); _setSimulationTimeWithNextCameraKeyframe = false; _saveRenderingCurrentRecordedTime = times.timeRec; } @@ -1169,11 +1169,11 @@ void SessionRecording::moveAheadInTime() { // Check if renderable in focus is still resolving tile loading // do not adjust time while we are doing this, or take screenshot const SceneGraphNode* focusNode = - global::navigationHandler.orbitalNavigator().anchorNode(); + global::navigationHandler->orbitalNavigator().anchorNode(); const Renderable* focusRenderable = focusNode->renderable(); if (!focusRenderable || focusRenderable->renderedWithDesiredData()) { _saveRenderingCurrentRecordedTime += _saveRenderingDeltaTime; - global::renderEngine.takeScreenshot(); + global::renderEngine->takeScreenshot(); } } } @@ -1348,17 +1348,17 @@ bool SessionRecording::processCameraKeyframe(double now) { // Need to activly update the focusNode position of the camera in relation to // the rendered objects will be unstable and actually incorrect - Camera* camera = global::navigationHandler.camera(); + Camera* camera = global::navigationHandler->camera(); Scene* scene = camera->parent()->scene(); const SceneGraphNode* n = scene->sceneGraphNode(_keyframesCamera[prevIdx].focusNode); if (n) { - global::navigationHandler.orbitalNavigator().setFocusNode(n->identifier()); + global::navigationHandler->orbitalNavigator().setFocusNode(n->identifier()); } return interaction::KeyframeNavigator::updateCamera( - global::navigationHandler.camera(), + global::navigationHandler->camera(), prevPose, nextPose, t, @@ -1379,7 +1379,7 @@ bool SessionRecording::processScriptKeyframe() { _keyframesScript, ([this]() { signalPlaybackFinishedForComponent(RecordedType::Script); }) ); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( nextScript, scripting::ScriptEngine::RemoteScripting::Yes ); diff --git a/src/interaction/sessionrecording_lua.inl b/src/interaction/sessionrecording_lua.inl index 303e647326..e2b47d8bd8 100644 --- a/src/interaction/sessionrecording_lua.inl +++ b/src/interaction/sessionrecording_lua.inl @@ -39,10 +39,10 @@ int startRecording(lua_State* L) { if (recordFilePath.empty()) { return luaL_error(L, "filepath string is empty"); } - global::sessionRecording.setRecordDataFormat( + global::sessionRecording->setRecordDataFormat( interaction::SessionRecording::DataMode::Binary ); - global::sessionRecording.startRecording(recordFilePath); + global::sessionRecording->startRecording(recordFilePath); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -62,10 +62,10 @@ int startRecordingAscii(lua_State* L) { if (recordFilePath.empty()) { return luaL_error(L, "filepath string is empty"); } - global::sessionRecording.setRecordDataFormat( + global::sessionRecording->setRecordDataFormat( interaction::SessionRecording::DataMode::Ascii ); - global::sessionRecording.startRecording(recordFilePath); + global::sessionRecording->startRecording(recordFilePath); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -74,7 +74,7 @@ int startRecordingAscii(lua_State* L) { int stopRecording(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::stopRecording"); - global::sessionRecording.stopRecording(); + global::sessionRecording->stopRecording(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -95,7 +95,7 @@ int startPlayback(lua_State* L, interaction::KeyframeTimeRef timeMode, return luaL_error(L, "filepath string is empty"); } - global::sessionRecording.startPlayback( + global::sessionRecording->startPlayback( playbackFilePath, timeMode, forceSimTimeAtStart @@ -136,7 +136,7 @@ int startPlaybackSimulationTime(lua_State* L) { int stopPlayback(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::stopPlayback"); - global::sessionRecording.stopPlayback(); + global::sessionRecording->stopPlayback(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -151,7 +151,7 @@ int enableTakeScreenShotDuringPlayback(lua_State* L) { const int fps = nArguments == 0 ? 60 : ghoul::lua::value(L, 1); - global::sessionRecording.enableTakeScreenShotDuringPlayback(fps); + global::sessionRecording->enableTakeScreenShotDuringPlayback(fps); lua_settop(L, 0); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -161,7 +161,7 @@ int enableTakeScreenShotDuringPlayback(lua_State* L) { int disableTakeScreenShotDuringPlayback(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::disableTakeScreenShotDuringPlayback"); - global::sessionRecording.disableTakeScreenShotDuringPlayback(); + global::sessionRecording->disableTakeScreenShotDuringPlayback(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; diff --git a/src/interaction/shortcutmanager_lua.inl b/src/interaction/shortcutmanager_lua.inl index 106bb0321f..fcce0b314a 100644 --- a/src/interaction/shortcutmanager_lua.inl +++ b/src/interaction/shortcutmanager_lua.inl @@ -52,7 +52,7 @@ namespace openspace::luascriptfunctions { int clearShortcuts(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clearShortcuts"); - global::shortcutManager.resetShortcuts(); + global::shortcutManager->resetShortcuts(); return 0; } @@ -60,7 +60,7 @@ int bindShortcut(lua_State* L) { int n = ghoul::lua::checkArgumentsAndThrow(L, { 2, 4 }, "lua::bindShortcut"); interaction::ShortcutManager::ShortcutInformation info = extractInfo(L, n, true); - global::shortcutManager.addShortcut(std::move(info)); + global::shortcutManager->addShortcut(std::move(info)); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -70,7 +70,7 @@ int bindShortcutLocal(lua_State* L) { int n = ghoul::lua::checkArgumentsAndThrow(L, { 2, 4 }, "lua::bindShortcutLocal"); interaction::ShortcutManager::ShortcutInformation info = extractInfo(L, n, false); - global::shortcutManager.addShortcut(std::move(info)); + global::shortcutManager->addShortcut(std::move(info)); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; diff --git a/src/mission/missionmanager_lua.inl b/src/mission/missionmanager_lua.inl index ca3269fcca..283e5c46cc 100644 --- a/src/mission/missionmanager_lua.inl +++ b/src/mission/missionmanager_lua.inl @@ -38,7 +38,7 @@ int loadMission(lua_State* L) { return ghoul::lua::luaError(L, "Filepath is empty"); } - std::string name = global::missionManager.loadMission(absPath(missionFileName)); + std::string name = global::missionManager->loadMission(absPath(missionFileName)); ghoul::lua::push(L, name); ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); @@ -57,11 +57,11 @@ int unloadMission(lua_State* L) { return ghoul::lua::luaError(L, "Mission name is empty"); } - if (!global::missionManager.hasMission(missionName)) { + if (!global::missionManager->hasMission(missionName)) { return ghoul::lua::luaError(L, "Mission was not previously loaded"); } - global::missionManager.unloadMission(missionName); + global::missionManager->unloadMission(missionName); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -79,7 +79,7 @@ int hasMission(lua_State* L) { return ghoul::lua::luaError(L, "Missing name is empty"); } - const bool hasMission = global::missionManager.hasMission(missionName); + const bool hasMission = global::missionManager->hasMission(missionName); ghoul::lua::push(L, hasMission); @@ -99,7 +99,7 @@ int setCurrentMission(lua_State* L) { return ghoul::lua::luaError(L, "Mission name is empty"); } - global::missionManager.setCurrentMission(missionName); + global::missionManager->setCurrentMission(missionName); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; diff --git a/src/network/parallelpeer.cpp b/src/network/parallelpeer.cpp index 7a6de5c9de..184ac07c1f 100644 --- a/src/network/parallelpeer.cpp +++ b/src/network/parallelpeer.cpp @@ -127,10 +127,10 @@ ParallelPeer::ParallelPeer() ParallelPeer::~ParallelPeer() { disconnect(); if (_timeJumpCallback != -1) { - global::timeManager.removeTimeJumpCallback(_timeJumpCallback); + global::timeManager->removeTimeJumpCallback(_timeJumpCallback); } if (_timeJumpCallback != -1) { - global::timeManager.removeTimeJumpCallback(_timeJumpCallback); + global::timeManager->removeTimeJumpCallback(_timeJumpCallback); } } @@ -227,7 +227,7 @@ void ParallelPeer::handleMessage(const ParallelConnection::Message& message) { void ParallelPeer::analyzeTimeDifference(double messageTimestamp) { std::lock_guard latencyLock(_latencyMutex); - const double timeDiff = global::windowDelegate.applicationTime() - messageTimestamp; + const double timeDiff = global::windowDelegate->applicationTime() - messageTimestamp; if (_latencyDiffs.empty()) { _initialTimeDiff = timeDiff; } @@ -283,7 +283,7 @@ void ParallelPeer::dataMessageReceived(const std::vector& message) datamessagestructures::CameraKeyframe kf(buffer); const double convertedTimestamp = convertTimestamp(kf._timestamp); - global::navigationHandler.keyframeNavigator().removeKeyframesAfter( + global::navigationHandler->keyframeNavigator().removeKeyframesAfter( convertedTimestamp ); @@ -294,16 +294,16 @@ void ParallelPeer::dataMessageReceived(const std::vector& message) pose.scale = kf._scale; pose.followFocusNodeRotation = kf._followNodeRotation; - global::navigationHandler.keyframeNavigator().addKeyframe(convertedTimestamp, + global::navigationHandler->keyframeNavigator().addKeyframe(convertedTimestamp, pose); break; } case datamessagestructures::Type::TimelineData: { - const double now = global::windowDelegate.applicationTime(); + const double now = global::windowDelegate->applicationTime(); datamessagestructures::TimeTimeline timelineMessage(buffer); if (timelineMessage._clear) { - global::timeManager.removeKeyframesAfter( + global::timeManager->removeKeyframesAfter( convertTimestamp(timestamp), true ); @@ -318,7 +318,7 @@ void ParallelPeer::dataMessageReceived(const std::vector& message) const double convertedTimestamp = convertTimestamp(keyframesMessage[0]._timestamp); - global::timeManager.removeKeyframesAfter(convertedTimestamp, true); + global::timeManager->removeKeyframesAfter(convertedTimestamp, true); } for (const datamessagestructures::TimeKeyframe& kfMessage : keyframesMessage) @@ -334,9 +334,9 @@ void ParallelPeer::dataMessageReceived(const std::vector& message) // We only need at least one keyframe before the current timestamp, // so we can remove any other previous ones if (kfTimestamp < now) { - global::timeManager.removeKeyframesBefore(kfTimestamp, true); + global::timeManager->removeKeyframesBefore(kfTimestamp, true); } - global::timeManager.addKeyframe( + global::timeManager->addKeyframe( kfTimestamp, timeKeyframeData ); @@ -347,7 +347,7 @@ void ParallelPeer::dataMessageReceived(const std::vector& message) datamessagestructures::ScriptMessage sm; sm.deserialize(buffer); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( sm._script, scripting::ScriptEngine::RemoteScripting::No ); @@ -407,8 +407,8 @@ void ParallelPeer::connectionStatusMessageReceived(const std::vector& mess setStatus(status); - global::navigationHandler.keyframeNavigator().clearKeyframes(); - global::timeManager.clearKeyframes(); + global::navigationHandler->keyframeNavigator().clearKeyframes(); + global::timeManager->clearKeyframes(); } void ParallelPeer::nConnectionsMessageReceived(const std::vector& message) @@ -487,7 +487,7 @@ void ParallelPeer::sendScript(std::string script) { std::vector buffer; sm.serialize(buffer); - double timestamp = global::windowDelegate.applicationTime(); + double timestamp = global::windowDelegate->applicationTime(); ParallelConnection::DataMessage message( datamessagestructures::Type::ScriptData, timestamp, @@ -497,8 +497,8 @@ void ParallelPeer::sendScript(std::string script) { } void ParallelPeer::resetTimeOffset() { - global::navigationHandler.keyframeNavigator().clearKeyframes(); - global::timeManager.clearKeyframes(); + global::navigationHandler->keyframeNavigator().clearKeyframes(); + global::timeManager->clearKeyframes(); std::lock_guard latencyLock(_latencyMutex); _latencyDiffs.clear(); } @@ -514,7 +514,7 @@ void ParallelPeer::preSynchronization() { } if (isHost()) { - double now = global::windowDelegate.applicationTime(); + double now = global::windowDelegate->applicationTime(); if (_lastCameraKeyframeTimestamp + _cameraKeyframeInterval < now) { sendCameraKeyframe(); @@ -541,19 +541,21 @@ void ParallelPeer::setStatus(ParallelConnection::Status status) { _connectionEvent->publish("statusChanged"); } if (isHost()) { - global::timeManager.addTimeJumpCallback([this]() { + global::timeManager->addTimeJumpCallback([this]() { _timeJumped = true; }); - global::timeManager.addTimelineChangeCallback([this]() { + global::timeManager->addTimelineChangeCallback([this]() { _timeTimelineChanged = true; }); } else { if (_timeJumpCallback != -1) { - global::timeManager.removeTimeJumpCallback(_timeJumpCallback); + global::timeManager->removeTimeJumpCallback(_timeJumpCallback); } if (_timeTimelineChangeCallback != -1) { - global::timeManager.removeTimelineChangeCallback(_timeTimelineChangeCallback); + global::timeManager->removeTimelineChangeCallback( + _timeTimelineChangeCallback + ); } } } @@ -589,7 +591,7 @@ const std::string& ParallelPeer::hostName() { } void ParallelPeer::sendCameraKeyframe() { - interaction::NavigationHandler& navHandler = global::navigationHandler; + interaction::NavigationHandler& navHandler = *global::navigationHandler; const SceneGraphNode* focusNode = navHandler.orbitalNavigator().anchorNode(); @@ -614,7 +616,7 @@ void ParallelPeer::sendCameraKeyframe() { kf._scale = navHandler.camera()->scaling(); // Timestamp as current runtime of OpenSpace instance - kf._timestamp = global::windowDelegate.applicationTime(); + kf._timestamp = global::windowDelegate->applicationTime(); // Create a buffer for the keyframe std::vector buffer; @@ -622,7 +624,7 @@ void ParallelPeer::sendCameraKeyframe() { // Fill the keyframe buffer kf.serialize(buffer); - const double timestamp = global::windowDelegate.applicationTime(); + const double timestamp = global::windowDelegate->applicationTime(); // Send message _connection.sendDataMessage(ParallelConnection::DataMessage( datamessagestructures::Type::CameraData, @@ -633,7 +635,7 @@ void ParallelPeer::sendCameraKeyframe() { void ParallelPeer::sendTimeTimeline() { // Create a keyframe with current position and orientation of camera - const Timeline& timeline = global::timeManager.timeline(); + const Timeline& timeline = global::timeManager->timeline(); std::deque> keyframes = timeline.keyframes(); datamessagestructures::TimeTimeline timelineMessage; @@ -658,10 +660,10 @@ void ParallelPeer::sendTimeTimeline() { // If time jumped this frame, this is represented in the keyframe. if (timeline.nKeyframes() == 0) { datamessagestructures::TimeKeyframe kfMessage; - kfMessage._time = global::timeManager.time().j2000Seconds(); - kfMessage._dt = global::timeManager.targetDeltaTime(); - kfMessage._paused = global::timeManager.isPaused(); - kfMessage._timestamp = global::windowDelegate.applicationTime(); + kfMessage._time = global::timeManager->time().j2000Seconds(); + kfMessage._dt = global::timeManager->targetDeltaTime(); + kfMessage._paused = global::timeManager->isPaused(); + kfMessage._timestamp = global::windowDelegate->applicationTime(); kfMessage._requiresTimeJump = _timeJumped; timelineMessage._keyframes.push_back(kfMessage); } @@ -671,7 +673,7 @@ void ParallelPeer::sendTimeTimeline() { // Fill the timeline buffer timelineMessage.serialize(buffer); - double timestamp = global::windowDelegate.applicationTime(); + double timestamp = global::windowDelegate->applicationTime(); // Send message _connection.sendDataMessage(ParallelConnection::DataMessage( datamessagestructures::Type::TimelineData, diff --git a/src/network/parallelpeer_lua.inl b/src/network/parallelpeer_lua.inl index 583e3eea07..b48c81337f 100644 --- a/src/network/parallelpeer_lua.inl +++ b/src/network/parallelpeer_lua.inl @@ -27,8 +27,8 @@ namespace openspace::luascriptfunctions { int connect(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::connect"); - if (global::windowDelegate.isMaster()) { - global::parallelPeer.connect(); + if (global::windowDelegate->isMaster()) { + global::parallelPeer->connect(); } ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -38,8 +38,8 @@ int connect(lua_State* L) { int disconnect(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::disconnect"); - if (global::windowDelegate.isMaster()) { - global::parallelPeer.connect(); + if (global::windowDelegate->isMaster()) { + global::parallelPeer->connect(); } ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -49,8 +49,8 @@ int disconnect(lua_State* L) { int requestHostship(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::requestHostship"); - if (global::windowDelegate.isMaster()) { - global::parallelPeer.requestHostship(); + if (global::windowDelegate->isMaster()) { + global::parallelPeer->requestHostship(); } ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -60,8 +60,8 @@ int requestHostship(lua_State* L) { int resignHostship(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::resignHostship"); - if (global::windowDelegate.isMaster()) { - global::parallelPeer.resignHostship(); + if (global::windowDelegate->isMaster()) { + global::parallelPeer->resignHostship(); } ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); diff --git a/src/query/query.cpp b/src/query/query.cpp index b4a0fc490a..76da802137 100644 --- a/src/query/query.cpp +++ b/src/query/query.cpp @@ -32,7 +32,7 @@ namespace openspace { Scene* sceneGraph() { - return global::renderEngine.scene(); + return global::renderEngine->scene(); } SceneGraphNode* sceneGraphNode(const std::string& name) { @@ -49,7 +49,7 @@ const Renderable* renderable(const std::string& name) { } properties::Property* property(const std::string& uri) { - properties::Property* property = global::rootPropertyOwner.property(uri); + properties::Property* property = global::rootPropertyOwner->property(uri); return property; } @@ -57,14 +57,14 @@ std::vector allProperties() { std::vector properties; std::vector p = - global::rootPropertyOwner.propertiesRecursive(); + global::rootPropertyOwner->propertiesRecursive(); properties.insert(properties.end(), p.begin(), p.end()); // The virtual property manager is not part of the rootProperty owner since it cannot // have an identifier or the "regex as identifier" trick would not work std::vector p2 = - global::virtualPropertyManager.propertiesRecursive(); + global::virtualPropertyManager->propertiesRecursive(); properties.insert(properties.end(), p2.begin(), p2.end()); diff --git a/src/rendering/dashboard_lua.inl b/src/rendering/dashboard_lua.inl index 7b61ff47ab..40ac6930f1 100644 --- a/src/rendering/dashboard_lua.inl +++ b/src/rendering/dashboard_lua.inl @@ -49,7 +49,7 @@ int addDashboardItem(lua_State* L) { lua_settop(L, 0); try { - global::dashboard.addDashboardItem(DashboardItem::createFromDictionary(d)); + global::dashboard->addDashboardItem(DashboardItem::createFromDictionary(d)); } catch (const ghoul::RuntimeError& e) { LERRORC("addDashboardItem", e.what()); @@ -75,7 +75,7 @@ int removeDashboardItem(lua_State* L) { std::string identifier = luaL_checkstring(L, -1); - global::dashboard.removeDashboardItem(identifier); + global::dashboard->removeDashboardItem(identifier); lua_settop(L, 0); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -90,7 +90,7 @@ int removeDashboardItem(lua_State* L) { int clearDashboardItems(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clearDashboardItems"); - global::dashboard.clearDashboardItems(); + global::dashboard->clearDashboardItems(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index 93d54d6f43..aae263a0a5 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -401,8 +401,8 @@ void FramebufferRenderer::initialize() { DownscaledVolumeUniformNames ); - global::raycasterManager.addListener(*this); - global::deferredcasterManager.addListener(*this); + global::raycasterManager->addListener(*this); + global::deferredcasterManager->addListener(*this); // Set Default Rendering OpenGL State glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); @@ -418,7 +418,7 @@ void FramebufferRenderer::initialize() { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Save State in Cache - global::renderEngine.openglStateCache().loadCurrentGLState(); + global::renderEngine->openglStateCache().loadCurrentGLState(); } void FramebufferRenderer::deinitialize() { @@ -452,8 +452,8 @@ void FramebufferRenderer::deinitialize() { glDeleteBuffers(1, &_vertexPositionBuffer); glDeleteVertexArrays(1, &_screenQuad); - global::raycasterManager.removeListener(*this); - global::deferredcasterManager.removeListener(*this); + global::raycasterManager->removeListener(*this); + global::deferredcasterManager->removeListener(*this); } void FramebufferRenderer::raycastersChanged(VolumeRaycaster&, @@ -992,7 +992,7 @@ void FramebufferRenderer::updateRaycastData() { _insideRaycastPrograms.clear(); const std::vector& raycasters = - global::raycasterManager.raycasters(); + global::raycasterManager->raycasters(); int nextId = 0; for (VolumeRaycaster* raycaster : raycasters) { @@ -1064,7 +1064,7 @@ void FramebufferRenderer::updateDeferredcastData() { _deferredcastPrograms.clear(); const std::vector& deferredcasters = - global::deferredcasterManager.deferredcasters(); + global::deferredcasterManager->deferredcasters(); int nextId = 0; for (Deferredcaster* caster : deferredcasters) { DeferredcastData data = { nextId++, "HELPER" }; @@ -1148,10 +1148,10 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); GLint viewport[4] = { 0 }; - global::renderEngine.openglStateCache().viewport(viewport); + global::renderEngine->openglStateCache().viewport(viewport); // Reset Render Pipeline State - global::renderEngine.openglStateCache().resetCachedStates(); + global::renderEngine->openglStateCache().resetCachedStates(); _pingPongIndex = 0; @@ -1165,13 +1165,13 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac TracyGpuZone("Deferred G-Buffer") GLint vp[4] = {viewport[0], viewport[1], _resolution.x, _resolution.y}; - global::renderEngine.openglStateCache().setViewportState(vp); + global::renderEngine->openglStateCache().setViewportState(vp); glBindFramebuffer(GL_FRAMEBUFFER, _gBuffers.framebuffer); glDrawBuffers(3, ColorAttachmentArray); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } - Time time = global::timeManager.time(); + Time time = global::timeManager->time(); RenderData data = { *camera, @@ -1287,7 +1287,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector glBindFramebuffer(GL_FRAMEBUFFER, _exitFramebuffer); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); GLint viewport[4] = { 0 }; - global::renderEngine.openglStateCache().viewport(viewport); + global::renderEngine->openglStateCache().viewport(viewport); ghoul::opengl::ProgramObject* exitProgram = _exitPrograms[raycaster].get(); if (exitProgram) { @@ -1305,7 +1305,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector static_cast(viewport[2] * s), static_cast(viewport[3] * s) }; - global::renderEngine.openglStateCache().setViewportState(newVP); + global::renderEngine->openglStateCache().setViewportState(newVP); if (_downscaleVolumeRendering.currentDownscaleFactor != s) { _downscaleVolumeRendering.currentDownscaleFactor = s; @@ -1402,7 +1402,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector } if (raycaster->downscaleRender() < 1.f) { - global::renderEngine.openglStateCache().setViewportState(viewport); + global::renderEngine->openglStateCache().setViewportState(viewport); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _gBuffers.framebuffer); writeDownscaledVolume(); } @@ -1540,7 +1540,7 @@ void FramebufferRenderer::updateRendererData() { dict.setValue("hdrExposure", std::to_string(_hdrExposure)); dict.setValue("disableHDR", std::to_string(_disableHDR)); _rendererData = dict; - global::renderEngine.setRendererData(dict); + global::renderEngine->setRendererData(dict); } } // namespace openspace diff --git a/src/rendering/loadingscreen.cpp b/src/rendering/loadingscreen.cpp index 8f7fb9fc0e..7b1d63f491 100644 --- a/src/rendering/loadingscreen.cpp +++ b/src/rendering/loadingscreen.cpp @@ -112,7 +112,7 @@ LoadingScreen::LoadingScreen(ShowMessage showMessage, ShowNodeNames showNodeName , _showProgressbar(showProgressbar) , _randomEngine(_randomDevice()) { - _loadingFont = global::fontManager.font( + _loadingFont = global::fontManager->font( "Loading", LoadingFontSize, ghoul::fontrendering::FontManager::Outline::No, @@ -120,7 +120,7 @@ LoadingScreen::LoadingScreen(ShowMessage showMessage, ShowNodeNames showNodeName ); if (_showMessage) { - _messageFont = global::fontManager.font( + _messageFont = global::fontManager->font( "Loading", MessageFontSize, ghoul::fontrendering::FontManager::Outline::No, @@ -129,7 +129,7 @@ LoadingScreen::LoadingScreen(ShowMessage showMessage, ShowNodeNames showNodeName } if (_showNodeNames) { - _itemFont = global::fontManager.font( + _itemFont = global::fontManager->font( "Loading", ItemFontSize, ghoul::fontrendering::FontManager::Outline::No, @@ -165,9 +165,9 @@ void LoadingScreen::render() { // We have to recalculate the positions here because we will not be informed about a // window size change - const glm::vec2 dpiScaling = global::windowDelegate.dpiScaling(); + const glm::vec2 dpiScaling = global::windowDelegate->dpiScaling(); const glm::ivec2 res = - glm::vec2(global::windowDelegate.currentSubwindowSize()) * dpiScaling; + glm::vec2(global::windowDelegate->currentSubwindowSize()) * dpiScaling; float screenAspectRatio = static_cast(res.x) / static_cast(res.y); @@ -485,7 +485,7 @@ void LoadingScreen::render() { glEnable(GL_DEPTH_TEST); std::this_thread::sleep_for(RefreshRate); - global::windowDelegate.swapBuffer(); + global::windowDelegate->swapBuffer(); FrameMarkEnd("Loading") } diff --git a/src/rendering/luaconsole.cpp b/src/rendering/luaconsole.cpp index 97eee2f20e..104f637218 100644 --- a/src/rendering/luaconsole.cpp +++ b/src/rendering/luaconsole.cpp @@ -209,23 +209,23 @@ void LuaConsole::initialize() { _commands.emplace_back(""); _activeCommand = _commands.size() - 1; - _font = global::fontManager.font( + _font = global::fontManager->font( FontName, EntryFontSize, ghoul::fontrendering::FontManager::Outline::No ); - _historyFont = global::fontManager.font( + _historyFont = global::fontManager->font( FontName, HistoryFontSize, ghoul::fontrendering::FontManager::Outline::No ); - global::parallelPeer.connectionEvent().subscribe( + global::parallelPeer->connectionEvent().subscribe( "luaConsole", "statusChanged", [this]() { - ParallelConnection::Status status = global::parallelPeer.status(); + ParallelConnection::Status status = global::parallelPeer->status(); parallelConnectionChanged(status); } ); @@ -265,7 +265,7 @@ void LuaConsole::deinitialize() { } } - global::parallelPeer.connectionEvent().unsubscribe("luaConsole"); + global::parallelPeer->connectionEvent().unsubscribe("luaConsole"); } bool LuaConsole::keyboardCallback(Key key, KeyModifier modifier, KeyAction action) { @@ -288,7 +288,7 @@ bool LuaConsole::keyboardCallback(Key key, KeyModifier modifier, KeyAction actio } else { _isVisible = true; - if (global::parallelPeer.status() == ParallelConnection::Status::Host) { + if (global::parallelPeer->status() == ParallelConnection::Status::Host) { _remoteScripting = true; } } @@ -428,7 +428,7 @@ bool LuaConsole::keyboardCallback(Key key, KeyModifier modifier, KeyAction actio std::string cmd = _commands.at(_activeCommand); if (!cmd.empty()) { using RemoteScripting = scripting::ScriptEngine::RemoteScripting; - global::scriptEngine.queueScript(cmd, RemoteScripting(_remoteScripting)); + global::scriptEngine->queueScript(cmd, RemoteScripting(_remoteScripting)); // Only add the current command to the history if it hasn't been // executed before. We don't want two of the same commands in a row @@ -457,7 +457,7 @@ bool LuaConsole::keyboardCallback(Key key, KeyModifier modifier, KeyAction actio if (_autoCompleteInfo.lastIndex != NoAutoComplete && modifierShift) { _autoCompleteInfo.lastIndex -= 2; } - std::vector allCommands = global::scriptEngine.allLuaFunctions(); + std::vector allCommands = global::scriptEngine->allLuaFunctions(); std::sort(allCommands.begin(), allCommands.end()); std::string currentCommand = _commands.at(_activeCommand); @@ -610,13 +610,13 @@ void LuaConsole::update() { // The first frame is going to be finished in approx 10 us, which causes a floating // point overflow when computing dHeight constexpr double Epsilon = 1e-4; - const double frametime = std::max(global::windowDelegate.deltaTime(), Epsilon); + const double frametime = std::max(global::windowDelegate->deltaTime(), Epsilon); // Update the current height. // The current height is the offset that is used to slide // the console in from the top. - const glm::ivec2 res = global::windowDelegate.currentSubwindowSize(); - const glm::vec2 dpiScaling = global::windowDelegate.dpiScaling(); + const glm::ivec2 res = global::windowDelegate->currentSubwindowSize(); + const glm::vec2 dpiScaling = global::windowDelegate->dpiScaling(); const double dHeight = (_targetHeight - _currentHeight) * std::pow(0.98, 1.0 / (ConsoleOpenSpeed / dpiScaling.y * frametime)); @@ -636,9 +636,9 @@ void LuaConsole::render() { return; } - const glm::vec2 dpiScaling = global::windowDelegate.dpiScaling(); + const glm::vec2 dpiScaling = global::windowDelegate->dpiScaling(); const glm::ivec2 res = - glm::vec2(global::windowDelegate.currentSubwindowSize()) / dpiScaling; + glm::vec2(global::windowDelegate->currentSubwindowSize()) / dpiScaling; // Render background @@ -790,10 +790,10 @@ void LuaConsole::render() { if (_remoteScripting) { const glm::vec4 Red(1.f, 0.f, 0.f, 1.f); - ParallelConnection::Status status = global::parallelPeer.status(); + ParallelConnection::Status status = global::parallelPeer->status(); const int nClients = status != ParallelConnection::Status::Disconnected ? - global::parallelPeer.nConnections() - 1 : + global::parallelPeer->nConnections() - 1 : 0; const std::string nClientsText = @@ -804,7 +804,7 @@ void LuaConsole::render() { const glm::vec2 loc = locationForRightJustifiedText(nClientsText); RenderFont(*_font, loc, nClientsText, Red); } - else if (global::parallelPeer.isHost()) { + else if (global::parallelPeer->isHost()) { const glm::vec4 LightBlue(0.4f, 0.4f, 1.f, 1.f); const std::string localExecutionText = "Local script execution"; diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index beae4048a4..6ed258b7e7 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -112,7 +112,7 @@ ghoul::mm_unique_ptr Renderable::createFromDictionary( Renderable* result = factory->create( renderableType, dictionary, - &global::memoryManager.PersistentMemory + &global::memoryManager->PersistentMemory ); return ghoul::mm_unique_ptr(result); } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 6c2c1a5965..b1ca205edc 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -365,8 +365,8 @@ RenderEngine::RenderEngine() addProperty(_applyWarping); _horizFieldOfView.onChange([this]() { - if (global::windowDelegate.isMaster()) { - global::windowDelegate.setHorizFieldOfView(_horizFieldOfView); + if (global::windowDelegate->isMaster()) { + global::windowDelegate->setHorizFieldOfView(_horizFieldOfView); } }); addProperty(_horizFieldOfView); @@ -417,11 +417,11 @@ void RenderEngine::initialize() { // We have to perform these initializations here as the OsEng has not been initialized // in our constructor - _globalRotation = static_cast(global::configuration.globalRotation); + _globalRotation = static_cast(global::configuration->globalRotation); _screenSpaceRotation = - static_cast(global::configuration.screenSpaceRotation); - _masterRotation = static_cast(global::configuration.masterRotation); - _disableMasterRendering = global::configuration.isRenderingOnMasterDisabled; + static_cast(global::configuration->screenSpaceRotation); + _masterRotation = static_cast(global::configuration->masterRotation); + _disableMasterRendering = global::configuration->isRenderingOnMasterDisabled; #ifdef GHOUL_USE_DEVIL ghoul::io::TextureReader::ref().addReader( @@ -452,8 +452,8 @@ void RenderEngine::initialize() { ); _versionString = OPENSPACE_VERSION_STRING_FULL; - if (global::versionChecker.hasLatestVersionInfo()) { - VersionChecker::SemanticVersion latest = global::versionChecker.latestVersion(); + if (global::versionChecker->hasLatestVersionInfo()) { + VersionChecker::SemanticVersion latest = global::versionChecker->latestVersion(); VersionChecker::SemanticVersion current{ OPENSPACE_VERSION_MAJOR, @@ -473,7 +473,7 @@ void RenderEngine::initializeGL() { LTRACE("RenderEngine::initializeGL(begin)"); - std::string renderingMethod = global::configuration.renderingMethod; + std::string renderingMethod = global::configuration->renderingMethod; if (renderingMethod == "ABuffer") { using Version = ghoul::systemcapabilities::Version; @@ -491,35 +491,35 @@ void RenderEngine::initializeGL() { // set the close clip plane and the far clip plane to extreme values while in // development - global::windowDelegate.setNearFarClippingPlane(0.001f, 1000.f); + global::windowDelegate->setNearFarClippingPlane(0.001f, 1000.f); // Set horizontal FOV value with whatever the field of view (in degrees) is of the // initialized window - _horizFieldOfView = static_cast(global::windowDelegate.getHorizFieldOfView()); + _horizFieldOfView = static_cast(global::windowDelegate->getHorizFieldOfView()); { ZoneScopedN("Font: Mono") TracyGpuZone("Font: Mono") constexpr const float FontSizeFrameinfo = 32.f; - _fontFrameInfo = global::fontManager.font(KeyFontMono, FontSizeFrameinfo); + _fontFrameInfo = global::fontManager->font(KeyFontMono, FontSizeFrameinfo); } { ZoneScopedN("Font: Date") TracyGpuZone("Font: Date") constexpr const float FontSizeTime = 15.f; - _fontDate = global::fontManager.font(KeyFontMono, FontSizeTime); + _fontDate = global::fontManager->font(KeyFontMono, FontSizeTime); } { ZoneScopedN("Font: Info") TracyGpuZone("Font: Info") constexpr const float FontSizeMono = 10.f; - _fontInfo = global::fontManager.font(KeyFontMono, FontSizeMono); + _fontInfo = global::fontManager->font(KeyFontMono, FontSizeMono); } { ZoneScopedN("Font: Log") TracyGpuZone("Font: Log") constexpr const float FontSizeLight = 8.f; - _fontLog = global::fontManager.font(KeyFontLight, FontSizeLight); + _fontLog = global::fontManager->font(KeyFontLight, FontSizeLight); } { @@ -549,8 +549,8 @@ void RenderEngine::updateScene() { _scene->updateInterpolations(); - const Time& currentTime = global::timeManager.time(); - const Time& integrateFromTime = global::timeManager.integrateFromTime(); + const Time& currentTime = global::timeManager->time(); + const Time& integrateFromTime = global::timeManager->integrateFromTime(); _scene->update({ TransformData{ glm::dvec3(0.0), glm::dmat3(1.0), glm::dvec3(1.0) }, @@ -579,7 +579,7 @@ void RenderEngine::updateShaderPrograms() { void RenderEngine::updateRenderer() { ZoneScoped - const bool windowResized = global::windowDelegate.windowHasResized(); + const bool windowResized = global::windowDelegate->windowHasResized(); if (windowResized) { _renderer->setResolution(renderingResolution()); @@ -589,7 +589,7 @@ void RenderEngine::updateRenderer() { FR::defaultProjectionRenderer().setFramebufferSize(renderingResolution()); //Override the aspect ratio property value to match that of resized window _horizFieldOfView = - static_cast(global::windowDelegate.getHorizFieldOfView()); + static_cast(global::windowDelegate->getHorizFieldOfView()); } _renderer->update(); @@ -598,22 +598,22 @@ void RenderEngine::updateRenderer() { void RenderEngine::updateScreenSpaceRenderables() { ZoneScoped - for (std::unique_ptr& ssr : global::screenSpaceRenderables) { + for (std::unique_ptr& ssr : *global::screenSpaceRenderables) { ssr->update(); } } glm::ivec2 RenderEngine::renderingResolution() const { - return global::windowDelegate.currentDrawBufferResolution(); + return global::windowDelegate->currentDrawBufferResolution(); } glm::ivec2 RenderEngine::fontResolution() const { - const std::string& value = global::configuration.onScreenTextScaling; + const std::string& value = global::configuration->onScreenTextScaling; if (value == "framebuffer") { - return global::windowDelegate.currentViewportSize(); + return global::windowDelegate->currentViewportSize(); } else { - return global::windowDelegate.currentSubwindowSize(); + return global::windowDelegate->currentSubwindowSize(); } } @@ -638,7 +638,7 @@ glm::mat4 RenderEngine::screenSpaceRotation() const { } glm::mat4 RenderEngine::nodeRotation() const { - if (!global::windowDelegate.isMaster()) { + if (!global::windowDelegate->isMaster()) { return glm::mat4(1.f); } glm::vec3 rot = _masterRotation; @@ -661,7 +661,7 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat LTRACE("RenderEngine::render(begin)"); - const WindowDelegate& delegate = global::windowDelegate; + const WindowDelegate& delegate = *global::windowDelegate; const glm::mat4 globalRot = globalRotation(); const glm::mat4 nodeRot = nodeRotation(); @@ -694,7 +694,7 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat ); std::string fn = std::to_string(_frameNumber); - WindowDelegate::Frustum frustum = global::windowDelegate.frustumMode(); + WindowDelegate::Frustum frustum = global::windowDelegate->frustumMode(); std::string fr = [](WindowDelegate::Frustum frustum) -> std::string { switch (frustum) { case WindowDelegate::Frustum::Mono: return ""; @@ -704,9 +704,9 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat } }(frustum); - std::string sgFn = std::to_string(global::windowDelegate.swapGroupFrameNumber()); - std::string dt = std::to_string(global::windowDelegate.deltaTime()); - std::string avgDt = std::to_string(global::windowDelegate.averageDeltaTime()); + std::string sgFn = std::to_string(global::windowDelegate->swapGroupFrameNumber()); + std::string dt = std::to_string(global::windowDelegate->deltaTime()); + std::string avgDt = std::to_string(global::windowDelegate->averageDeltaTime()); std::string res = "Frame: " + fn + ' ' + fr + '\n' + "Swap group frame: " + sgFn + '\n' + @@ -718,9 +718,9 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat ZoneScopedN("Render Screenspace Renderable") std::vector ssrs; - ssrs.reserve(global::screenSpaceRenderables.size()); + ssrs.reserve(global::screenSpaceRenderables->size()); for (const std::unique_ptr& ssr : - global::screenSpaceRenderables) + *global::screenSpaceRenderables) { if (ssr->isEnabled() && ssr->isReady()) { ssrs.push_back(ssr.get()); @@ -760,7 +760,7 @@ bool RenderEngine::mouseActivationCallback(const glm::dvec2& mousePosition) cons local f = 'NavigationHandler.OrbitalNavigator.Friction.RotationalFriction'; openspace.setPropertyValueSingle(f, not openspace.getPropertyValue(f));)"; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( ToggleRotationFrictionScript, scripting::ScriptEngine::RemoteScripting::Yes ); @@ -772,7 +772,7 @@ bool RenderEngine::mouseActivationCallback(const glm::dvec2& mousePosition) cons local f = 'NavigationHandler.OrbitalNavigator.Friction.ZoomFriction'; openspace.setPropertyValueSingle(f, not openspace.getPropertyValue(f));)"; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( ToggleZoomFrictionScript, scripting::ScriptEngine::RemoteScripting::Yes ); @@ -784,7 +784,7 @@ bool RenderEngine::mouseActivationCallback(const glm::dvec2& mousePosition) cons local f = 'NavigationHandler.OrbitalNavigator.Friction.RollFriction'; openspace.setPropertyValueSingle(f, not openspace.getPropertyValue(f));)"; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( ToggleRollFrictionScript, scripting::ScriptEngine::RemoteScripting::Yes ); @@ -797,7 +797,7 @@ bool RenderEngine::mouseActivationCallback(const glm::dvec2& mousePosition) cons void RenderEngine::renderOverlays(const ShutdownInformation& shutdownInfo) { ZoneScoped - const bool isMaster = global::windowDelegate.isMaster(); + const bool isMaster = global::windowDelegate->isMaster(); if (isMaster || _showOverlayOnSlaves) { renderScreenLog(); renderVersionInformation(); @@ -824,9 +824,9 @@ void RenderEngine::renderEndscreen() { glm::vec4(0.f, 0.f, 0.f, 0.5f) ); - const glm::vec2 dpiScaling = global::windowDelegate.dpiScaling(); + const glm::vec2 dpiScaling = global::windowDelegate->dpiScaling(); const glm::ivec2 res = - glm::vec2(global::windowDelegate.currentSubwindowSize()) / dpiScaling; + glm::vec2(global::windowDelegate->currentSubwindowSize()) / dpiScaling; glViewport(0, 0, res.x, res.y); using FR = ghoul::fontrendering::FontRenderer; @@ -872,13 +872,13 @@ void RenderEngine::renderShutdownInformation(float timer, float fullTime) { void RenderEngine::renderDashboard() { ZoneScoped - glm::vec2 dashboardStart = global::dashboard.getStartPositionOffset(); + glm::vec2 dashboardStart = global::dashboard->getStartPositionOffset(); glm::vec2 penPosition = glm::vec2( dashboardStart.x, - dashboardStart.y + fontResolution().y - global::luaConsole.currentHeight() + dashboardStart.y + fontResolution().y - global::luaConsole->currentHeight() ); - global::dashboard.render(penPosition); + global::dashboard->render(penPosition); #ifdef REALTIME_CAMERA_POS_DISPLAY penPosition += glm::vec2(0.f, -50.f); @@ -1098,7 +1098,7 @@ void RenderEngine::takeScreenshot() { ); } - _latestScreenshotNumber = global::windowDelegate.takeScreenshot(_applyWarping); + _latestScreenshotNumber = global::windowDelegate->takeScreenshot(_applyWarping); } /** @@ -1183,11 +1183,11 @@ void RenderEngine::addScreenSpaceRenderable(std::unique_ptridentifier(); if (std::find_if( - global::screenSpaceRenderables.begin(), - global::screenSpaceRenderables.end(), + global::screenSpaceRenderables->begin(), + global::screenSpaceRenderables->end(), [&identifier](const std::unique_ptr& ssr) { return ssr->identifier() == identifier; - }) != global::screenSpaceRenderables.end() + }) != global::screenSpaceRenderables->end() ) { LERROR(fmt::format( "Cannot add scene space renderable. " @@ -1200,22 +1200,22 @@ void RenderEngine::addScreenSpaceRenderable(std::unique_ptrinitialize(); s->initializeGL(); - global::screenSpaceRootPropertyOwner.addPropertySubOwner(s.get()); - global::screenSpaceRenderables.push_back(std::move(s)); + global::screenSpaceRootPropertyOwner->addPropertySubOwner(s.get()); + global::screenSpaceRenderables->push_back(std::move(s)); } void RenderEngine::removeScreenSpaceRenderable(ScreenSpaceRenderable* s) { const auto it = std::find_if( - global::screenSpaceRenderables.begin(), - global::screenSpaceRenderables.end(), + global::screenSpaceRenderables->begin(), + global::screenSpaceRenderables->end(), [s](const std::unique_ptr& r) { return r.get() == s; } ); - if (it != global::screenSpaceRenderables.end()) { + if (it != global::screenSpaceRenderables->end()) { s->deinitialize(); - global::screenSpaceRootPropertyOwner.removePropertySubOwner(s); + global::screenSpaceRootPropertyOwner->removePropertySubOwner(s); - global::screenSpaceRenderables.erase(it); + global::screenSpaceRenderables->erase(it); } } @@ -1230,14 +1230,14 @@ ScreenSpaceRenderable* RenderEngine::screenSpaceRenderable( const std::string& identifier) { const auto it = std::find_if( - global::screenSpaceRenderables.begin(), - global::screenSpaceRenderables.end(), + global::screenSpaceRenderables->begin(), + global::screenSpaceRenderables->end(), [&identifier](const std::unique_ptr& s) { return s->identifier() == identifier; } ); - if (it != global::screenSpaceRenderables.end()) { + if (it != global::screenSpaceRenderables->end()) { return it->get(); } else { @@ -1246,10 +1246,10 @@ ScreenSpaceRenderable* RenderEngine::screenSpaceRenderable( } std::vector RenderEngine::screenSpaceRenderables() const { - std::vector res(global::screenSpaceRenderables.size()); + std::vector res(global::screenSpaceRenderables->size()); std::transform( - global::screenSpaceRenderables.begin(), - global::screenSpaceRenderables.end(), + global::screenSpaceRenderables->begin(), + global::screenSpaceRenderables->end(), res.begin(), [](const std::unique_ptr& p) { return p.get(); } ); @@ -1292,7 +1292,7 @@ void RenderEngine::renderCameraInformation() { constexpr const float XSeparation = 5.f; const interaction::OrbitalNavigator& nav = - global::navigationHandler.orbitalNavigator(); + global::navigationHandler->orbitalNavigator(); using FR = ghoul::fontrendering::FontRenderer; diff --git a/src/rendering/renderengine_lua.inl b/src/rendering/renderengine_lua.inl index 8a5e933f43..f671ab7213 100644 --- a/src/rendering/renderengine_lua.inl +++ b/src/rendering/renderengine_lua.inl @@ -44,7 +44,7 @@ int setRenderer(lua_State* L) { 1, ghoul::lua::PopValue::Yes ); - global::renderEngine.setRendererFromString(renderer); + global::renderEngine->setRendererFromString(renderer); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -69,7 +69,7 @@ int addScreenSpaceRenderable(lua_State* L) { std::unique_ptr s = ScreenSpaceRenderable::createFromDictionary(d); - global::renderEngine.addScreenSpaceRenderable(std::move(s)); + global::renderEngine->addScreenSpaceRenderable(std::move(s)); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -83,7 +83,7 @@ int removeScreenSpaceRenderable(lua_State* L) { 1, ghoul::lua::PopValue::Yes ); - global::renderEngine.removeScreenSpaceRenderable(name); + global::renderEngine->removeScreenSpaceRenderable(name); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -92,8 +92,8 @@ int removeScreenSpaceRenderable(lua_State* L) { int takeScreenshot(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::takeScreenshot"); - global::renderEngine.takeScreenshot(); - const unsigned int screenshotNumber = global::renderEngine.latestScreenshotNumber(); + global::renderEngine->takeScreenshot(); + const unsigned int screenshotNumber = global::renderEngine->latestScreenshotNumber(); lua_pushinteger(L, screenshotNumber); return 1; diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index 49df254322..8b0f561038 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -316,7 +316,8 @@ std::unique_ptr ScreenSpaceRenderable::createFromDictiona } std::string ScreenSpaceRenderable::makeUniqueIdentifier(std::string name) { - std::vector r = global::renderEngine.screenSpaceRenderables(); + std::vector r = + global::renderEngine->screenSpaceRenderables(); auto nameTaken = [&r](const std::string& name) { bool nameTaken = std::any_of( @@ -459,7 +460,7 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary _delete.onChange([this](){ std::string script = "openspace.removeScreenSpaceRenderable('" + identifier() + "');"; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( script, scripting::ScriptEngine::RemoteScripting::No ); @@ -484,7 +485,7 @@ bool ScreenSpaceRenderable::deinitialize() { bool ScreenSpaceRenderable::deinitializeGL() { if (_shader) { - global::renderEngine.removeRenderProgram(_shader.get()); + global::renderEngine->removeRenderProgram(_shader.get()); _shader = nullptr; } @@ -521,13 +522,13 @@ float ScreenSpaceRenderable::depth() { void ScreenSpaceRenderable::createShaders() { ghoul::Dictionary dict = ghoul::Dictionary(); - auto res = global::windowDelegate.currentDrawBufferResolution(); + auto res = global::windowDelegate->currentDrawBufferResolution(); ghoul::Dictionary rendererData = { { "fragmentRendererPath", "${SHADERS}/framebuffer/renderframebuffer.frag" }, { "windowWidth" , res.x }, { "windowHeight" , res.y }, - { "hdrExposure", global::renderEngine.hdrExposure() }, - { "disableHDR", global::renderEngine.isHdrDisabled() } + { "hdrExposure", global::renderEngine->hdrExposure() }, + { "disableHDR", global::renderEngine->isHdrDisabled() } }; dict.setValue("rendererData", rendererData); @@ -543,7 +544,7 @@ void ScreenSpaceRenderable::createShaders() { } glm::mat4 ScreenSpaceRenderable::scaleMatrix() { - glm::vec2 resolution = global::windowDelegate.currentDrawBufferResolution(); + glm::vec2 resolution = global::windowDelegate->currentDrawBufferResolution(); //to scale the plane float textureRatio = @@ -571,12 +572,12 @@ glm::mat4 ScreenSpaceRenderable::globalRotationMatrix() { // 2) sgct's scene matrix (also called model matrix by sgct) glm::mat4 inverseRotation = glm::inverse( - global::renderEngine.globalRotation() * - global::windowDelegate.modelMatrix() + global::renderEngine->globalRotation() * + global::windowDelegate->modelMatrix() ); // The rotation of all screen space renderables is adjustable in the render engine: - return global::renderEngine.screenSpaceRotation() * inverseRotation; + return global::renderEngine->screenSpaceRotation() * inverseRotation; } glm::mat4 ScreenSpaceRenderable::localRotationMatrix() { @@ -617,7 +618,7 @@ void ScreenSpaceRenderable::draw(glm::mat4 modelTransform) { _shader->setUniform( _uniformCache.viewProj, - global::renderEngine.scene()->camera()->viewProjectionMatrix() + global::renderEngine->scene()->camera()->viewProjectionMatrix() ); ghoul::opengl::TextureUnit unit; diff --git a/src/scene/assetmanager.cpp b/src/scene/assetmanager.cpp index 80e892309f..de1809110f 100644 --- a/src/scene/assetmanager.cpp +++ b/src/scene/assetmanager.cpp @@ -65,7 +65,7 @@ bool AssetManager::update() { const bool add = c.second; if (add) { _assetLoader.add(path); - global::profile.addAsset(path); + global::profile->addAsset(path); } } // Remove assets @@ -75,7 +75,7 @@ bool AssetManager::update() { const bool remove = !c.second; if (remove && _assetLoader.has(path)) { _assetLoader.remove(path); - global::profile.removeAsset(path); + global::profile->removeAsset(path); } } _pendingStateChangeCommands.clear(); diff --git a/src/scene/assetmanager_lua.inl b/src/scene/assetmanager_lua.inl index 6458165b58..b6e2705da1 100644 --- a/src/scene/assetmanager_lua.inl +++ b/src/scene/assetmanager_lua.inl @@ -40,13 +40,13 @@ int add(lua_State* state) { ghoul::lua::PopValue::Yes ); - if (global::renderEngine.scene()) { + if (global::renderEngine->scene()) { assetManager->add(assetName); } else { // The scene might not exist yet if OpenSpace was started without specifying an // initial asset - global::openSpaceEngine.scheduleLoadSingleAsset(assetName); + global::openSpaceEngine->scheduleLoadSingleAsset(assetName); } diff --git a/src/scene/profile.cpp b/src/scene/profile.cpp index 14308a08b8..5f8b389c45 100644 --- a/src/scene/profile.cpp +++ b/src/scene/profile.cpp @@ -473,7 +473,7 @@ void Profile::saveCurrentSettingsToProfile(const properties::PropertyOwner& root _time = t; // Delta times - std::vector dts = global::timeManager.deltaTimeSteps(); + std::vector dts = global::timeManager->deltaTimeSteps(); _deltaTimes = std::move(dts); // Camera diff --git a/src/scene/profile_lua.inl b/src/scene/profile_lua.inl index 970eb5ac45..a009f1d07d 100644 --- a/src/scene/profile_lua.inl +++ b/src/scene/profile_lua.inl @@ -35,7 +35,7 @@ namespace openspace::luascriptfunctions { int saveSettingsToProfile(lua_State* L) { - if (!global::configuration.usingProfile) { + if (!global::configuration->usingProfile) { return luaL_error( L, "Program was not started with a profile, so cannot use this " @@ -51,7 +51,7 @@ int saveSettingsToProfile(lua_State* L) { std::string saveFilePath; if (n == 0) { - const ghoul::filesystem::File f = global::configuration.profile; + const ghoul::filesystem::File f = global::configuration->profile; std::time_t t = std::time(nullptr); std::tm* utcTime = std::gmtime(&t); @@ -68,13 +68,13 @@ int saveSettingsToProfile(lua_State* L) { ); std::string newFile = fmt::format("{}_{}", f.fullBaseName(), time); std::string sourcePath = - absPath("${PROFILES}") + '/' + global::configuration.profile + ".profile"; + absPath("${PROFILES}") + '/' + global::configuration->profile + ".profile"; std::string destPath = absPath("${PROFILES}") + '/' + newFile + ".profile"; LINFOC("Profile", fmt::format("Saving a copy of the old profile as {}", newFile)); std::filesystem::copy(sourcePath, destPath); - saveFilePath = global::configuration.profile; + saveFilePath = global::configuration->profile; } else { saveFilePath = ghoul::lua::value(L, 1); @@ -83,12 +83,12 @@ int saveSettingsToProfile(lua_State* L) { } } - const properties::PropertyOwner& root = global::rootPropertyOwner; - std::string currentTime = std::string(global::timeManager.time().ISO8601()); + const properties::PropertyOwner& root = *global::rootPropertyOwner; + std::string currentTime = std::string(global::timeManager->time().ISO8601()); interaction::NavigationHandler::NavigationState navState = - global::navigationHandler.navigationState(); - global::profile.saveCurrentSettingsToProfile(root, currentTime, navState); - global::configuration.profile = saveFilePath; + global::navigationHandler->navigationState(); + global::profile->saveCurrentSettingsToProfile(root, currentTime, navState); + global::configuration->profile = saveFilePath; if (saveFilePath.find('/') != std::string::npos) { return luaL_error(L, "Profile filename must not contain path (/) elements"); @@ -128,7 +128,7 @@ int saveSettingsToProfile(lua_State* L) { } try { - outFile << global::profile.serialize(); + outFile << global::profile->serialize(); } catch (const std::ofstream::failure& e) { return luaL_error( diff --git a/src/scene/rotation.cpp b/src/scene/rotation.cpp index 9c26296f87..05266dc4ab 100644 --- a/src/scene/rotation.cpp +++ b/src/scene/rotation.cpp @@ -71,7 +71,7 @@ ghoul::mm_unique_ptr Rotation::createFromDictionary( Rotation* result = factory->create( rotationType, dictionary, - &global::memoryManager.PersistentMemory + &global::memoryManager->PersistentMemory ); return ghoul::mm_unique_ptr(result); } diff --git a/src/scene/scale.cpp b/src/scene/scale.cpp index 2083dcb172..3035a22884 100644 --- a/src/scene/scale.cpp +++ b/src/scene/scale.cpp @@ -69,7 +69,7 @@ ghoul::mm_unique_ptr Scale::createFromDictionary(const ghoul::Dictionary& Scale* result = factory->create( scaleType, dictionary, - &global::memoryManager.PersistentMemory + &global::memoryManager->PersistentMemory ); result->setIdentifier("Scale"); return ghoul::mm_unique_ptr(result); diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 9af3720b5a..a822d94dd4 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -110,12 +110,12 @@ void applyRegularExpression(lua_State* L, const std::string& regex, foundMatching = true; if (interpolationDuration == 0.0) { - global::renderEngine.scene()->removePropertyInterpolation(prop); + global::renderEngine->scene()->removePropertyInterpolation(prop); prop->setLuaValue(L); } else { prop->setLuaInterpolationTarget(L); - global::renderEngine.scene()->addPropertyInterpolation( + global::renderEngine->scene()->addPropertyInterpolation( prop, static_cast(interpolationDuration), easingFunction @@ -188,12 +188,12 @@ int setPropertyCall_single(properties::Property& prop, const std::string& uri, } else { if (duration == 0.0) { - global::renderEngine.scene()->removePropertyInterpolation(&prop); + global::renderEngine->scene()->removePropertyInterpolation(&prop); prop.setLuaValue(L); } else { prop.setLuaInterpolationTarget(L); - global::renderEngine.scene()->addPropertyInterpolation( + global::renderEngine->scene()->addPropertyInterpolation( &prop, static_cast(duration), easingFunction @@ -499,7 +499,7 @@ int loadScene(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::loadScene"); const std::string& sceneFile = ghoul::lua::value(L, 1); - global::openSpaceEngine.scheduleLoadSingleAsset(sceneFile); + global::openSpaceEngine->scheduleLoadSingleAsset(sceneFile); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -518,13 +518,13 @@ int addSceneGraphNode(lua_State* L) { } try { - SceneGraphNode* node = global::renderEngine.scene()->loadNode(d); + SceneGraphNode* node = global::renderEngine->scene()->loadNode(d); if (!node) { LERRORC("Scene", "Could not load scene graph node"); return ghoul::lua::luaError(L, "Error loading scene graph node"); } - global::renderEngine.scene()->initializeNode(node); + global::renderEngine->scene()->initializeNode(node); } catch (const documentation::SpecificationError& e) { return ghoul::lua::luaError( @@ -599,7 +599,7 @@ int removeSceneGraphNodesFromRegex(lua_State* L) { std::string name = ghoul::lua::value(L, 1, ghoul::lua::PopValue::Yes); const std::vector& nodes = - global::renderEngine.scene()->allSceneGraphNodes(); + global::renderEngine->scene()->allSceneGraphNodes(); // Replace all wildcards * with the correct regex (.*) size_t startPos = name.find("*"); @@ -697,7 +697,7 @@ int hasSceneGraphNode(lua_State* L) { 1, ghoul::lua::PopValue::Yes ); - SceneGraphNode* node = global::renderEngine.scene()->sceneGraphNode(nodeName); + SceneGraphNode* node = global::renderEngine->scene()->sceneGraphNode(nodeName); ghoul::lua::push(L, node != nullptr); @@ -712,7 +712,7 @@ int addInterestingTime(lua_State* L) { std::string time = ghoul::lua::value(L, 2, ghoul::lua::PopValue::No); lua_pop(L, 2); - global::renderEngine.scene()->addInterestingTime( + global::renderEngine->scene()->addInterestingTime( { std::move(name), std::move(time) } ); diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 1492495241..aebb135f3c 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -154,7 +154,7 @@ ghoul::mm_unique_ptr SceneGraphNode::createFromDictionary( "SceneGraphNode" ); - SceneGraphNode* n = global::memoryManager.PersistentMemory.alloc(); + SceneGraphNode* n = global::memoryManager->PersistentMemory.alloc(); ghoul::mm_unique_ptr result = ghoul::mm_unique_ptr(n); #ifdef Debugging_Core_SceneGraphNode_Indices @@ -332,13 +332,13 @@ SceneGraphNode::SceneGraphNode() , _guiDescription(GuiDescriptionInfo) , _transform { ghoul::mm_unique_ptr( - global::memoryManager.PersistentMemory.alloc() + global::memoryManager->PersistentMemory.alloc() ), ghoul::mm_unique_ptr( - global::memoryManager.PersistentMemory.alloc() + global::memoryManager->PersistentMemory.alloc() ), ghoul::mm_unique_ptr( - global::memoryManager.PersistentMemory.alloc() + global::memoryManager->PersistentMemory.alloc() ) } , _boundingSphere(properties::FloatProperty(BoundingSphereInfo, 0.f)) @@ -689,7 +689,7 @@ void SceneGraphNode::computeScreenSpaceData(RenderData& newData) { return; } - glm::ivec2 res = global::windowDelegate.currentSubwindowSize(); + glm::ivec2 res = global::windowDelegate->currentSubwindowSize(); // Get the radius of node double nodeRadius = static_cast(this->boundingSphere()); diff --git a/src/scene/sceneinitializer.cpp b/src/scene/sceneinitializer.cpp index 06d166d7ff..b03039c5ac 100644 --- a/src/scene/sceneinitializer.cpp +++ b/src/scene/sceneinitializer.cpp @@ -52,7 +52,7 @@ MultiThreadedSceneInitializer::MultiThreadedSceneInitializer(unsigned int nThrea void MultiThreadedSceneInitializer::initializeNode(SceneGraphNode* node) { auto initFunction = [this, node]() { - LoadingScreen* loadingScreen = global::openSpaceEngine.loadingScreen(); + LoadingScreen* loadingScreen = global::openSpaceEngine->loadingScreen(); LoadingScreen::ProgressInfo progressInfo; progressInfo.progress = 1.f; @@ -83,7 +83,7 @@ void MultiThreadedSceneInitializer::initializeNode(SceneGraphNode* node) { LoadingScreen::ProgressInfo progressInfo; progressInfo.progress = 0.f; - LoadingScreen* loadingScreen = global::openSpaceEngine.loadingScreen(); + LoadingScreen* loadingScreen = global::openSpaceEngine->loadingScreen(); if (loadingScreen) { loadingScreen->setItemNumber(loadingScreen->itemNumber() + 1); loadingScreen->updateItem( diff --git a/src/scene/scenelicensewriter.cpp b/src/scene/scenelicensewriter.cpp index 38297042ab..42dd91f544 100644 --- a/src/scene/scenelicensewriter.cpp +++ b/src/scene/scenelicensewriter.cpp @@ -51,7 +51,7 @@ std::string SceneLicenseWriter::generateJson() const { json << "["; std::vector assets = - global::openSpaceEngine.assetManager().rootAsset().subTreeAssets(); + global::openSpaceEngine->assetManager().rootAsset().subTreeAssets(); int metaTotal = 0; for (const Asset* asset : assets) { diff --git a/src/scene/translation.cpp b/src/scene/translation.cpp index 44fea72bfc..a7491cfef2 100644 --- a/src/scene/translation.cpp +++ b/src/scene/translation.cpp @@ -70,7 +70,7 @@ ghoul::mm_unique_ptr Translation::createFromDictionary( Translation* result = factory->create( translationType, dictionary, - &global::memoryManager.PersistentMemory + &global::memoryManager->PersistentMemory ); result->setIdentifier("Translation"); return ghoul::mm_unique_ptr(result); diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index 8ff0a2e935..05260f7de1 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -54,7 +54,7 @@ ScriptEngine::ScriptEngine() } ) { - tracy::LuaRegister(_state); + //tracy::LuaRegister(_state); } void ScriptEngine::initialize() { @@ -634,8 +634,8 @@ bool ScriptEngine::writeLog(const std::string& script) { // Check that logging is enabled and initialize if necessary if (!_logFileExists) { // If a ScriptLogFile was specified, generate it now - if (!global::configuration.scriptLog.empty()) { - _logFilename = absPath(global::configuration.scriptLog); + if (!global::configuration->scriptLog.empty()) { + _logFilename = absPath(global::configuration->scriptLog); _logFileExists = true; LDEBUG(fmt::format( @@ -690,11 +690,11 @@ void ScriptEngine::preSync(bool isMaster) { // Not really a received script but the master also needs to run the script... _masterScriptQueue.push(item); - if (global::parallelPeer.isHost() && remoteScripting) { - global::parallelPeer.sendScript(item.script); + if (global::parallelPeer->isHost() && remoteScripting) { + global::parallelPeer->sendScript(item.script); } - if (global::sessionRecording.isRecording()) { - global::sessionRecording.saveScriptKeyframe(item.script); + if (global::sessionRecording->isRecording()) { + global::sessionRecording->saveScriptKeyframe(item.script); } } } diff --git a/src/scripting/scriptengine_lua.inl b/src/scripting/scriptengine_lua.inl index 562d8c9600..e27ddeb283 100644 --- a/src/scripting/scriptengine_lua.inl +++ b/src/scripting/scriptengine_lua.inl @@ -383,8 +383,8 @@ int unzipFile(lua_State* L) { * Saves the last entry from the script log to the current profile */ int saveLastChangeToProfile(lua_State* L) { - std::string asset = global::configuration.asset; - std::string logFilePath = absPath(global::configuration.scriptLog); + std::string asset = global::configuration->asset; + std::string logFilePath = absPath(global::configuration->scriptLog); std::ifstream logfile(logFilePath); std::string actualLastLine; std::string lastLine; diff --git a/src/scripting/scriptscheduler_lua.inl b/src/scripting/scriptscheduler_lua.inl index 699e2c2f0d..0d8bbe44cb 100644 --- a/src/scripting/scriptscheduler_lua.inl +++ b/src/scripting/scriptscheduler_lua.inl @@ -38,7 +38,7 @@ int loadFile(lua_State* L) { return ghoul::lua::luaError(L, "filepath string is empty"); } - global::scriptScheduler.loadScripts( + global::scriptScheduler->loadScripts( ghoul::lua::loadDictionaryFromFile(missionFileName, L) ); @@ -57,7 +57,7 @@ int loadScheduledScript(lua_State* L) { std::string forwardScript = ghoul::lua::value(L, 2); if (nArguments == 2) { - global::scriptScheduler.loadScripts({ + global::scriptScheduler->loadScripts({ { "1", ghoul::Dictionary { @@ -69,7 +69,7 @@ int loadScheduledScript(lua_State* L) { } else if (nArguments == 3) { std::string backwardScript = ghoul::lua::value(L, 3); - global::scriptScheduler.loadScripts({ + global::scriptScheduler->loadScripts({ { "1", ghoul::Dictionary { @@ -84,7 +84,7 @@ int loadScheduledScript(lua_State* L) { std::string backwardScript = ghoul::lua::value(L, 3); std::string universalScript = ghoul::lua::value(L, 4); - global::scriptScheduler.loadScripts({ + global::scriptScheduler->loadScripts({ { "1", ghoul::Dictionary { @@ -106,7 +106,7 @@ int loadScheduledScript(lua_State* L) { int setModeApplicationTime(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::setModeApplicationTime"); - global::scriptScheduler.setModeApplicationTime(); + global::scriptScheduler->setModeApplicationTime(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -115,7 +115,7 @@ int setModeApplicationTime(lua_State* L) { int setModeRecordedTime(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::setModeRecordedTime"); - global::scriptScheduler.setModeRecordedTime(); + global::scriptScheduler->setModeRecordedTime(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -124,7 +124,7 @@ int setModeRecordedTime(lua_State* L) { int setModeSimulationTime(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::setModeSimulationTime"); - global::scriptScheduler.setModeSimulationTime(); + global::scriptScheduler->setModeSimulationTime(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; @@ -133,7 +133,7 @@ int setModeSimulationTime(lua_State* L) { int clear(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clear"); - global::scriptScheduler.clearSchedule(); + global::scriptScheduler->clearSchedule(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; diff --git a/src/util/time.cpp b/src/util/time.cpp index 9c0820aaf5..a448438b19 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -91,7 +91,9 @@ void Time::setTime(const char* time) { std::string_view Time::UTC() const { constexpr const char Format[] = "YYYY MON DDTHR:MN:SC.### ::RND"; - char* b = reinterpret_cast(global::memoryManager.TemporaryMemory.allocate(32)); + char* b = reinterpret_cast( + global::memoryManager->TemporaryMemory.allocate(32) + ); std::memset(b, 0, 32); SpiceManager::ref().dateFromEphemerisTime(_time, b, 32, Format); @@ -104,7 +106,9 @@ std::string_view Time::ISO8601() const { constexpr const char Format[] = "YYYY-MM-DDTHR:MN:SC.###"; constexpr const int S = sizeof(Format); - char* b = reinterpret_cast(global::memoryManager.TemporaryMemory.allocate(S)); + char* b = reinterpret_cast( + global::memoryManager->TemporaryMemory.allocate(S) + ); std::memset(b, 0, S); SpiceManager::ref().dateFromEphemerisTime(_time, b, S, Format); diff --git a/src/util/time_lua.inl b/src/util/time_lua.inl index 59fa6dc04b..fe5cc9fadd 100644 --- a/src/util/time_lua.inl +++ b/src/util/time_lua.inl @@ -55,7 +55,7 @@ int time_setDeltaTime(lua_State* L) { return luaL_error(L, "bad argument #%d (%s)", 2, msg); } const double newDeltaTime = lua_tonumber(L, 1); - global::timeManager.setDeltaTime(newDeltaTime); + global::timeManager->setDeltaTime(newDeltaTime); } else { lua_settop(L, 0); @@ -98,7 +98,7 @@ int time_setDeltaTimeSteps(lua_State* L) { } lua_pop(L, 1); - global::timeManager.setDeltaTimeSteps(inputDeltaTimes); + global::timeManager->setDeltaTimeSteps(inputDeltaTimes); lua_settop(L, 0); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -114,7 +114,7 @@ int time_setDeltaTimeSteps(lua_State* L) { int time_setNextDeltaTimeStep(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::time_setNextDeltaTimeStep"); - global::timeManager.setNextDeltaTimeStep(); + global::timeManager->setNextDeltaTimeStep(); lua_settop(L, 0); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -130,7 +130,7 @@ int time_setNextDeltaTimeStep(lua_State* L) { int time_setPreviousDeltaTimeStep(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::time_setPreviousDeltaTimeStep"); - global::timeManager.setPreviousDeltaTimeStep(); + global::timeManager->setPreviousDeltaTimeStep(); lua_settop(L, 0); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -153,7 +153,7 @@ int time_interpolateNextDeltaTimeStep(lua_State* L) { ); double interpolationDuration = - global::timeManager.defaultDeltaTimeInterpolationDuration(); + global::timeManager->defaultDeltaTimeInterpolationDuration(); const int nArguments = lua_gettop(L); if (nArguments == 1) { @@ -171,7 +171,7 @@ int time_interpolateNextDeltaTimeStep(lua_State* L) { interpolationDuration = lua_tonumber(L, 1); } - global::timeManager.interpolateNextDeltaTimeStep(interpolationDuration); + global::timeManager->interpolateNextDeltaTimeStep(interpolationDuration); lua_settop(L, 0); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -194,7 +194,7 @@ int time_interpolatePreviousDeltaTimeStep(lua_State* L) { ); double interpolationDuration = - global::timeManager.defaultDeltaTimeInterpolationDuration(); + global::timeManager->defaultDeltaTimeInterpolationDuration(); const int nArguments = lua_gettop(L); if (nArguments == 1) { @@ -212,7 +212,7 @@ int time_interpolatePreviousDeltaTimeStep(lua_State* L) { interpolationDuration = lua_tonumber(L, 1); } - global::timeManager.interpolatePreviousDeltaTimeStep(interpolationDuration); + global::timeManager->interpolatePreviousDeltaTimeStep(interpolationDuration); lua_settop(L, 0); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -256,7 +256,7 @@ int time_interpolateDeltaTime(lua_State* L) { const double interpolationDuration = lua_tonumber(L, 2); const double newDeltaTime = lua_tonumber(L, 1); - global::timeManager.interpolateDeltaTime(newDeltaTime, interpolationDuration); + global::timeManager->interpolateDeltaTime(newDeltaTime, interpolationDuration); } else if (nArguments == 1) { const bool isNumber = (lua_isnumber(L, 1) != 0); @@ -271,9 +271,9 @@ int time_interpolateDeltaTime(lua_State* L) { return luaL_error(L, "bad argument #%d (%s)", 2, msg); } const double newDeltaTime = lua_tonumber(L, 1); - global::timeManager.interpolateDeltaTime( + global::timeManager->interpolateDeltaTime( newDeltaTime, - global::timeManager.defaultDeltaTimeInterpolationDuration() + global::timeManager->defaultDeltaTimeInterpolationDuration() ); } else { @@ -295,7 +295,7 @@ int time_interpolateDeltaTime(lua_State* L) { * Returns the delta time by calling the Time::deltaTime method */ int time_deltaTime(lua_State* L) { - lua_pushnumber(L, global::timeManager.deltaTime()); + lua_pushnumber(L, global::timeManager->deltaTime()); ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } @@ -309,7 +309,7 @@ int time_togglePause(lua_State* L) { const int nArguments = lua_gettop(L); if (nArguments == 0) { - global::timeManager.setPause(!global::timeManager.isPaused()); + global::timeManager->setPause(!global::timeManager->isPaused()); } else { lua_settop(L, 0); @@ -350,17 +350,17 @@ int time_interpolateTogglePause(lua_State* L) { const double interpolationDuration = lua_tonumber(L, 1); - global::timeManager.interpolatePause( - !global::timeManager.isPaused(), + global::timeManager->interpolatePause( + !global::timeManager->isPaused(), interpolationDuration ); } else if (nArguments == 0) { - const bool pause = !global::timeManager.isPaused(); - global::timeManager.interpolatePause(pause, + const bool pause = !global::timeManager->isPaused(); + global::timeManager->interpolatePause(pause, pause ? - global::timeManager.defaultPauseInterpolationDuration() : - global::timeManager.defaultUnpauseInterpolationDuration() + global::timeManager->defaultPauseInterpolationDuration() : + global::timeManager->defaultUnpauseInterpolationDuration() ); } else { @@ -388,7 +388,7 @@ int time_setPause(lua_State* L) { if (nArguments == 1) { const bool pause = lua_toboolean(L, 1) == 1; - global::timeManager.setPause(pause); + global::timeManager->setPause(pause); } else { lua_settop(L, 0); @@ -429,14 +429,14 @@ int time_interpolatePause(lua_State* L) { } const double interpolationDuration = lua_tonumber(L, 2); const bool pause = lua_toboolean(L, 1) == 1; - global::timeManager.interpolatePause(pause, interpolationDuration); + global::timeManager->interpolatePause(pause, interpolationDuration); } else if (nArguments == 1) { const bool pause = lua_toboolean(L, 1) == 1; - global::timeManager.interpolatePause(pause, + global::timeManager->interpolatePause(pause, pause ? - global::timeManager.defaultPauseInterpolationDuration() : - global::timeManager.defaultUnpauseInterpolationDuration() + global::timeManager->defaultPauseInterpolationDuration() : + global::timeManager->defaultUnpauseInterpolationDuration() ); } else { @@ -488,12 +488,12 @@ int time_setTime(lua_State* L) { if (nArguments == 1) { if (isNumber) { double value = lua_tonumber(L, 1); - global::timeManager.setTimeNextFrame(Time(value)); + global::timeManager->setTimeNextFrame(Time(value)); return 0; } if (isString) { const char* time = lua_tostring(L, 1); - global::timeManager.setTimeNextFrame(Time(Time::convertTime(time))); + global::timeManager->setTimeNextFrame(Time(Time::convertTime(time))); return 0; } ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -541,17 +541,17 @@ int time_interpolateTime(lua_State* L) { if (lua_gettop(L) == 1) { if (isNumber) { double value = lua_tonumber(L, 1); - global::timeManager.interpolateTime( + global::timeManager->interpolateTime( value, - global::timeManager.defaultTimeInterpolationDuration() + global::timeManager->defaultTimeInterpolationDuration() ); return 0; } if (isString) { const char* time = lua_tostring(L, 1); - global::timeManager.interpolateTime( + global::timeManager->interpolateTime( Time::convertTime(time), - global::timeManager.defaultTimeInterpolationDuration() + global::timeManager->defaultTimeInterpolationDuration() ); return 0; } @@ -577,10 +577,10 @@ int time_interpolateTime(lua_State* L) { const double duration = lua_tonumber(L, 2); if (duration > 0) { - global::timeManager.interpolateTime(targetTime, duration); + global::timeManager->interpolateTime(targetTime, duration); } else { - global::timeManager.setTimeNextFrame(Time(targetTime)); + global::timeManager->setTimeNextFrame(Time(targetTime)); } } return 0; @@ -615,9 +615,9 @@ int time_interpolateTimeRelative(lua_State* L) { if (lua_gettop(L) == 1 && isNumber) { double delta = lua_tonumber(L, 1); - global::timeManager.interpolateTimeRelative( + global::timeManager->interpolateTimeRelative( delta, - global::timeManager.defaultTimeInterpolationDuration() + global::timeManager->defaultTimeInterpolationDuration() ); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -638,11 +638,11 @@ int time_interpolateTimeRelative(lua_State* L) { const double duration = lua_tonumber(L, 2); if (duration > 0) { - global::timeManager.interpolateTimeRelative(delta, duration); + global::timeManager->interpolateTimeRelative(delta, duration); } else { - global::timeManager.setTimeNextFrame( - Time(global::timeManager.time().j2000Seconds() + delta) + global::timeManager->setTimeNextFrame( + Time(global::timeManager->time().j2000Seconds() + delta) ); } } @@ -656,7 +656,7 @@ int time_interpolateTimeRelative(lua_State* L) { * It is returned by calling the Time::currentTime method. */ int time_currentTime(lua_State* L) { - ghoul::lua::push(L, global::timeManager.time().j2000Seconds()); + ghoul::lua::push(L, global::timeManager->time().j2000Seconds()); ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } @@ -668,7 +668,7 @@ int time_currentTime(lua_State* L) { * timezone by calling the Time::UTC method */ int time_currentTimeUTC(lua_State* L) { - ghoul::lua::push(L, global::timeManager.time().UTC()); + ghoul::lua::push(L, global::timeManager->time().UTC()); ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } diff --git a/src/util/timemanager.cpp b/src/util/timemanager.cpp index 67beb6c0ca..d9a9b526c8 100644 --- a/src/util/timemanager.cpp +++ b/src/util/timemanager.cpp @@ -112,7 +112,7 @@ TimeManager::TimeManager() void TimeManager::interpolateTime(double targetTime, double durationSeconds) { ghoul_precondition(durationSeconds > 0.f, "durationSeconds must be positive"); - const double now = global::windowDelegate.applicationTime(); + const double now = global::windowDelegate->applicationTime(); const bool pause = isPaused(); const TimeKeyframeData current = { time(), deltaTime(), false, false }; @@ -126,10 +126,10 @@ void TimeManager::interpolateTime(double targetTime, double durationSeconds) { void TimeManager::interpolateTimeRelative(double delta, double durationSeconds) { ghoul_precondition(durationSeconds > 0.f, "durationSeconds must be positive"); - const float duration = global::timeManager.defaultTimeInterpolationDuration(); + const float duration = global::timeManager->defaultTimeInterpolationDuration(); const TimeKeyframeData predictedTime = interpolate( - global::windowDelegate.applicationTime() + duration + global::windowDelegate->applicationTime() + duration ); const double targetTime = predictedTime.time.j2000Seconds() + delta; interpolateTime(targetTime, durationSeconds); @@ -262,7 +262,7 @@ void TimeManager::progressTime(double dt) { return; } - const double now = global::windowDelegate.applicationTime(); + const double now = global::windowDelegate->applicationTime(); const std::deque>& keyframes = _timeline.keyframes(); auto firstFutureKeyframe = std::lower_bound( @@ -455,7 +455,7 @@ void TimeManager::addDeltaTimesKeybindings() { auto addDeltaTimeKeybind = [this](Key key, KeyModifier mod, double step) { const std::string s = fmt::format("{:.0f}", step); - global::keybindingManager.bindKeyLocal( + global::keybindingManager->bindKeyLocal( key, mod, fmt::format("openspace.time.interpolateDeltaTime({})", s), @@ -507,7 +507,7 @@ void TimeManager::addDeltaTimesKeybindings() { void TimeManager::clearDeltaTimesKeybindings() { for (const KeyWithModifier& kb : _deltaTimeStepKeybindings) { // Check if there are multiple keys bound to the same key - auto bindings = global::keybindingManager.keyBinding(kb); + auto bindings = global::keybindingManager->keyBinding(kb); if (bindings.size() > 1) { std::string names; for (auto& b : bindings) { @@ -519,7 +519,7 @@ void TimeManager::clearDeltaTimesKeybindings() { ghoul::to_string(kb), names )); } - global::keybindingManager.removeKeyBinding(kb); + global::keybindingManager->removeKeyBinding(kb); } _deltaTimeStepKeybindings.clear(); } @@ -716,7 +716,7 @@ void TimeManager::interpolateDeltaTime(double newDeltaTime, double interpolation return; } - const double now = global::windowDelegate.applicationTime(); + const double now = global::windowDelegate->applicationTime(); Time newTime( time().j2000Seconds() + (_deltaTime + newDeltaTime) * 0.5 * interpolationDuration ); @@ -812,7 +812,7 @@ void TimeManager::interpolatePause(bool pause, double interpolationDuration) { return; } - const double now = global::windowDelegate.applicationTime(); + const double now = global::windowDelegate->applicationTime(); double targetDelta = pause ? 0.0 : _targetDeltaTime; Time newTime( time().j2000Seconds() + (_deltaTime + targetDelta) * 0.5 * interpolationDuration diff --git a/src/util/touch.cpp b/src/util/touch.cpp index f08c5cab03..0c3d7ce7c1 100644 --- a/src/util/touch.cpp +++ b/src/util/touch.cpp @@ -44,7 +44,7 @@ glm::vec2 TouchInput::screenCoordinates(glm::vec2 resolution) const { } glm::vec2 TouchInput::currentWindowCoordinates() const { - glm::vec2 res = global::windowDelegate.currentSubwindowSize(); + glm::vec2 res = global::windowDelegate->currentSubwindowSize(); return { std::floor(x * res.x + 0.5f), std::floor(y * res.y + 0.5f) }; } diff --git a/support/cmake/handle_modules.cmake b/support/cmake/handle_modules.cmake index fc0178d699..b6258833f8 100644 --- a/support/cmake/handle_modules.cmake +++ b/support/cmake/handle_modules.cmake @@ -80,6 +80,10 @@ function (handle_modules internal_module_path external_modules_paths) # set(dependencies "") list(LENGTH enabled_module_names enabled_module_count) + if (${enabled_module_count} EQUAL 0) + message(STATUS "No modules selected") + return() + endif () math(EXPR enabled_module_count "${enabled_module_count} - 1") foreach (val RANGE ${enabled_module_count}) list(GET enabled_module_names ${val} name) diff --git a/tests/main.cpp b/tests/main.cpp index 69319043d3..11e7afe2d8 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -53,9 +53,9 @@ int main(int argc, char** argv) { ); std::string configFile = configuration::findConfiguration(); - global::configuration = configuration::loadConfigurationFromFile(configFile); - global::openSpaceEngine.registerPathTokens(); - global::openSpaceEngine.initialize(); + *global::configuration = configuration::loadConfigurationFromFile(configFile); + global::openSpaceEngine->registerPathTokens(); + global::openSpaceEngine->initialize(); FileSys.registerPathToken("${TESTDIR}", "${BASE}/tests"); @@ -66,6 +66,6 @@ int main(int argc, char** argv) { // And the deinitialization needs the SpiceManager to be initialized openspace::SpiceManager::initialize(); - global::openSpaceEngine.deinitialize(); + global::openSpaceEngine->deinitialize(); return result; } diff --git a/tests/test_assetloader.cpp b/tests/test_assetloader.cpp index 59aa57da43..097d7694cd 100644 --- a/tests/test_assetloader.cpp +++ b/tests/test_assetloader.cpp @@ -52,7 +52,7 @@ namespace { TEST_CASE("AssetLoader: Assertion", "[assetloader]") { openspace::Scene scene(std::make_unique()); - ghoul::lua::LuaState* state = openspace::global::scriptEngine.luaState(); + ghoul::lua::LuaState* state = openspace::global::scriptEngine->luaState(); openspace::SynchronizationWatcher syncWatcher; openspace::AssetLoader assetLoader( state, @@ -66,7 +66,7 @@ TEST_CASE("AssetLoader: Assertion", "[assetloader]") { TEST_CASE("AssetLoader: Basic Export Import", "[assetloader]") { openspace::Scene scene(std::make_unique()); - ghoul::lua::LuaState* state = openspace::global::scriptEngine.luaState(); + ghoul::lua::LuaState* state = openspace::global::scriptEngine->luaState(); openspace::SynchronizationWatcher syncWatcher; openspace::AssetLoader assetLoader( state, @@ -79,7 +79,7 @@ TEST_CASE("AssetLoader: Basic Export Import", "[assetloader]") { TEST_CASE("AssetLoader: Asset Functions", "[assetloader]") { openspace::Scene scene(std::make_unique()); - ghoul::lua::LuaState* state = openspace::global::scriptEngine.luaState(); + ghoul::lua::LuaState* state = openspace::global::scriptEngine->luaState(); openspace::SynchronizationWatcher syncWatcher; openspace::AssetLoader assetLoader( state, @@ -92,7 +92,7 @@ TEST_CASE("AssetLoader: Asset Functions", "[assetloader]") { TEST_CASE("AssetLoader: Asset Initialization", "[assetloader]") { openspace::Scene scene(std::make_unique()); - ghoul::lua::LuaState* state = openspace::global::scriptEngine.luaState(); + ghoul::lua::LuaState* state = openspace::global::scriptEngine->luaState(); openspace::SynchronizationWatcher syncWatcher; openspace::AssetLoader assetLoader( state,