diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index d074fc737a..d4628cd9c6 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -224,6 +224,8 @@ void mainInitFunc(GLFWwindow*) { global::openSpaceEngine->initialize(); LDEBUG("Initializing OpenSpace Engine finished"); +#ifndef __APPLE__ + // Apparently: "Cocoa: Regular windows do not have icons on macOS" { std::string path = absPath("${DATA}/openspace-icon.png"); int x; @@ -242,6 +244,7 @@ void mainInitFunc(GLFWwindow*) { stbi_image_free(icons[0].pixels); } +#endif // __APPLE__ currentWindow = Engine::instance().windows().front().get(); currentViewport = currentWindow->viewports().front().get(); @@ -1012,7 +1015,6 @@ std::string selectedSgctProfileFromLauncher(LauncherWindow& lw, bool hasCliSGCTC } int main(int argc, char** argv) { - glfwInit(); #ifdef WIN32 SetUnhandledExceptionFilter(generateMiniDump); @@ -1169,19 +1171,38 @@ int main(int argc, char** argv) { sgctFunctionName ); + // (abock, 2020-12-07) For some reason on Apple the keyboard handler in CEF will call + // the Qt one even if the QApplication was destroyed, leading to invalid memory + // access. The only way we could fix this for the release was to keep the + // QApplication object around until the end of the program. Even though the Qt + // keyboard handler gets called, it doesn't do anything so everything still works. +#ifdef __APPLE__ + int qac = 0; + QApplication app(qac, nullptr); +#endif // __APPLE__ + bool skipLauncher = (hasProfile && hasSGCTConfig) || global::configuration->bypassLauncher; if (!skipLauncher) { +#ifndef __APPLE__ int qac = 0; QApplication app(qac, nullptr); - LauncherWindow win(!hasProfile, - *global::configuration, !hasSGCTConfig, windowCfgPreset, nullptr); +#endif // __APPLE__ + + LauncherWindow win( + !hasProfile, + *global::configuration, + !hasSGCTConfig, + windowCfgPreset, + nullptr + ); win.show(); app.exec(); if (!win.wasLaunchSelected()) { exit(EXIT_SUCCESS); } + glfwInit(); global::configuration->profile = win.selectedProfile(); windowConfiguration = selectedSgctProfileFromLauncher( @@ -1191,6 +1212,8 @@ int main(int argc, char** argv) { labelFromCfgFile, xmlExt ); + } else { + glfwInit(); } if (global::configuration->profile.empty()) { LFATAL("Cannot launch with an empty profile"); diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset index 635c56d9f0..2a91bf1261 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset @@ -3,7 +3,7 @@ local satelliteHelper = asset.require('util/tle_helper') local transforms = asset.require('scene/solarsystem/planets/earth/transforms') local sunTransforms = asset.require('scene/solarsystem/sun/transforms') -local url = "https://celestrak.com/satcat/tle.php?CATNR=25544" +local url = "http://celestrak.com/satcat/tle.php?CATNR=25544" local identifier = "ISS" local filename = "ISS.txt" local nodes = {} diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/aqua.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/aqua.asset index 9d2587e1fd..9ebe43df49 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/aqua.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/aqua.asset @@ -3,7 +3,7 @@ local satelliteHelper = asset.require('util/tle_helper') local transforms = asset.require('scene/solarsystem/planets/earth/transforms') local sunTransforms = asset.require('scene/solarsystem/sun/transforms') -local url = "https://celestrak.com/satcat/tle.php?CATNR=27424" +local url = "http://celestrak.com/satcat/tle.php?CATNR=27424" local identifier = "Aqua" local filename = "Aqua.txt" local nodes = {} diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/snpp.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/snpp.asset index ff812053a1..2b251d229d 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/snpp.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/snpp.asset @@ -3,7 +3,7 @@ local satelliteHelper = asset.require('util/tle_helper') local transforms = asset.require('scene/solarsystem/planets/earth/transforms') local sunTransforms = asset.require('scene/solarsystem/sun/transforms') -local url = "https://celestrak.com/satcat/tle.php?CATNR=37849" +local url = "http://celestrak.com/satcat/tle.php?CATNR=37849" local identifier = "SNPP" local filename = "SNPP.txt" local nodes = {} diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/weather/terra.asset b/data/assets/scene/solarsystem/planets/earth/satellites/weather/terra.asset index 0cdae52344..3d064550ee 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/weather/terra.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/weather/terra.asset @@ -3,7 +3,7 @@ local satelliteHelper = asset.require('util/tle_helper') local transforms = asset.require('scene/solarsystem/planets/earth/transforms') local sunTransforms = asset.require('scene/solarsystem/sun/transforms') -local url = "https://celestrak.com/satcat/tle.php?CATNR=25994" +local url = "http://celestrak.com/satcat/tle.php?CATNR=25994" local identifier = "Terra" local filename = "Terra.txt" local nodes = {} diff --git a/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/HiRISE.asset b/data/assets/scene/solarsystem/planets/mars/layers/colorlayers/hirise.asset similarity index 100% rename from data/assets/scene/solarsystem/planets/mars/layers/colorlayers/HiRISE.asset rename to data/assets/scene/solarsystem/planets/mars/layers/colorlayers/hirise.asset diff --git a/include/openspace/engine/globalscallbacks.h b/include/openspace/engine/globalscallbacks.h index 9131294139..cc06979e97 100644 --- a/include/openspace/engine/globalscallbacks.h +++ b/include/openspace/engine/globalscallbacks.h @@ -31,62 +31,26 @@ #include #include -namespace openspace::global { +namespace openspace::global::callback { -namespace detail { - -std::vector>& gInitialize(); -std::vector>& gDeinitialize(); - -std::vector>& gInitializeGL(); -std::vector>& gDeinitializeGL(); - -std::vector>& gPreSync(); -std::vector>& gPostSyncPreDraw(); -std::vector>& gRender(); -std::vector>& gDraw2D(); -std::vector>& gPostDraw(); - -std::vector>& gKeyboard(); -std::vector>& gCharacter(); - -std::vector>& gMouseButton(); -std::vector>& gMousePosition(); -std::vector>& gMouseScrollWheel(); - -std::vector>& gTouchDetected(); -std::vector>& gTouchUpdated(); -std::vector>& gTouchExit(); - -} // namespace detail - -namespace callback { - -static std::vector>& initialize = detail::gInitialize(); -static std::vector>& deinitialize = detail::gDeinitialize(); -static std::vector>& initializeGL = detail::gInitializeGL(); -static std::vector>& deinitializeGL = detail::gDeinitializeGL(); -static std::vector>& preSync = detail::gPreSync(); -static std::vector>& postSyncPreDraw = detail::gPostSyncPreDraw(); -static std::vector>& render = detail::gRender(); -static std::vector>& draw2D = detail::gDraw2D(); -static std::vector>& postDraw = detail::gPostDraw(); -static std::vector>& keyboard = - detail::gKeyboard(); -static std::vector>& character = - detail::gCharacter(); -static std::vector>& - mouseButton = detail::gMouseButton(); -static std::vector>& mousePosition = - detail::gMousePosition(); -static std::vector>& mouseScrollWheel = - detail::gMouseScrollWheel(); -static std::vector>& touchDetected = - detail::gTouchDetected(); -static std::vector>& touchUpdated = - detail::gTouchUpdated(); -static std::vector>& touchExit = - detail::gTouchExit(); +inline std::vector>* initialize; +inline std::vector>* deinitialize; +inline std::vector>* initializeGL; +inline std::vector>* deinitializeGL; +inline std::vector>* preSync; +inline std::vector>* postSyncPreDraw; +inline std::vector>* render; +inline std::vector>* draw2D; +inline std::vector>* postDraw; +inline std::vector>* keyboard; +inline std::vector>* character; +inline std::vector>* + mouseButton; +inline std::vector>* mousePosition; +inline std::vector>* mouseScrollWheel; +inline std::vector>* touchDetected; +inline std::vector>* touchUpdated; +inline std::vector>* touchExit; /** * If the framerate becomes slow, Chromium Embedded Framework (used in Web Browser Module) @@ -99,7 +63,8 @@ static std::vector>& touchExit = */ extern void (*webBrowserPerformanceHotfix)(); -} // namespace callback +void create(); +void destroy(); } // namespace openspace::global diff --git a/modules/cefwebgui/cefwebguimodule.cpp b/modules/cefwebgui/cefwebguimodule.cpp index ceecc0e650..71b0967697 100644 --- a/modules/cefwebgui/cefwebguimodule.cpp +++ b/modules/cefwebgui/cefwebguimodule.cpp @@ -206,11 +206,11 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) _visible = configuration.hasValue(VisibleInfo.identifier) && configuration.value(VisibleInfo.identifier); - global::callback::initializeGL.emplace_back([this]() { + global::callback::initializeGL->emplace_back([this]() { startOrStopGui(); }); - global::callback::draw2D.emplace_back([this](){ + global::callback::draw2D->emplace_back([this](){ ZoneScopedN("CefWebGuiModule") const bool isGuiWindow = @@ -233,7 +233,7 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) } }); - global::callback::deinitializeGL.emplace_back([this]() { + global::callback::deinitializeGL->emplace_back([this]() { ZoneScopedN("CefWebGuiModule") if (_endpointCallback != -1) { diff --git a/modules/cefwebgui/src/guikeyboardhandler.cpp b/modules/cefwebgui/src/guikeyboardhandler.cpp index ef534d0095..3711fa0629 100644 --- a/modules/cefwebgui/src/guikeyboardhandler.cpp +++ b/modules/cefwebgui/src/guikeyboardhandler.cpp @@ -31,7 +31,7 @@ namespace openspace { GUIKeyboardHandler::GUIKeyboardHandler() { _keyConsumed = false; - global::callback::keyboard.emplace_back( + global::callback::keyboard->emplace_back( [&](Key, KeyModifier, KeyAction) -> bool { const bool previous = _keyConsumed; _keyConsumed = false; diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index e7e36ddaa1..6a36997952 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -216,7 +216,7 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) { // Initialize - global::callback::initializeGL.emplace_back([&]() { + global::callback::initializeGL->emplace_back([&]() { ZoneScopedN("GlobeBrowsingModule") _tileCache = std::make_unique(_tileCacheSizeMB); @@ -232,7 +232,7 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) { addPropertySubOwner(GdalWrapper::ref()); }); - global::callback::deinitializeGL.emplace_back([]() { + global::callback::deinitializeGL->emplace_back([]() { ZoneScopedN("GlobeBrowsingModule") tileprovider::deinitializeDefaultTile(); @@ -240,14 +240,14 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) { // Render - global::callback::render.emplace_back([&]() { + global::callback::render->emplace_back([&]() { ZoneScopedN("GlobeBrowsingModule") _tileCache->update(); }); // Deinitialize - global::callback::deinitialize.emplace_back([&]() { + global::callback::deinitialize->emplace_back([&]() { ZoneScopedN("GlobeBrowsingModule") GdalWrapper::destroy(); diff --git a/modules/imgui/imguimodule.cpp b/modules/imgui/imguimodule.cpp index 50bc8dbe78..02ce4f908e 100644 --- a/modules/imgui/imguimodule.cpp +++ b/modules/imgui/imguimodule.cpp @@ -44,7 +44,7 @@ namespace openspace { ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { addPropertySubOwner(gui); - global::callback::initialize.emplace_back([&]() { + global::callback::initialize->emplace_back([&]() { LDEBUGC("ImGUIModule", "Initializing GUI"); gui.initialize(); @@ -130,28 +130,28 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { ); }); - global::callback::deinitialize.emplace_back([&]() { + global::callback::deinitialize->emplace_back([&]() { ZoneScopedN("ImGUI") LDEBUGC("ImGui", "Deinitialize GUI"); gui.deinitialize(); }); - global::callback::initializeGL.emplace_back([&]() { + global::callback::initializeGL->emplace_back([&]() { ZoneScopedN("ImGUI") LDEBUGC("ImGui", "Initializing GUI OpenGL"); gui.initializeGL(); }); - global::callback::deinitializeGL.emplace_back([&]() { + global::callback::deinitializeGL->emplace_back([&]() { ZoneScopedN("ImGUI") LDEBUGC("ImGui", "Deinitialize GUI OpenGL"); gui.deinitializeGL(); }); - global::callback::draw2D.emplace_back([&]() { + global::callback::draw2D->emplace_back([&]() { ZoneScopedN("ImGUI") WindowDelegate& delegate = *global::windowDelegate; @@ -179,7 +179,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { } }); - global::callback::keyboard.emplace_back( + global::callback::keyboard->emplace_back( [&](Key key, KeyModifier mod, KeyAction action) -> bool { ZoneScopedN("ImGUI") @@ -193,7 +193,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { } ); - global::callback::character.emplace_back( + global::callback::character->emplace_back( [&](unsigned int codepoint, KeyModifier modifier) -> bool { ZoneScopedN("ImGUI") @@ -207,13 +207,13 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { } ); - global::callback::mousePosition.emplace_back( + global::callback::mousePosition->emplace_back( [&](double x, double y) { _mousePosition = glm::vec2(static_cast(x), static_cast(y)); } ); - global::callback::mouseButton.emplace_back( + global::callback::mouseButton->emplace_back( [&](MouseButton button, MouseAction action, KeyModifier) -> bool { ZoneScopedN("ImGUI") @@ -234,7 +234,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { } ); - global::callback::mouseScrollWheel.emplace_back( + global::callback::mouseScrollWheel->emplace_back( [&](double, double posY) -> bool { ZoneScopedN("ImGUI") @@ -248,19 +248,19 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { } ); - global::callback::touchDetected.emplace_back( + global::callback::touchDetected->emplace_back( [&](TouchInput input) -> bool { return gui.touchDetectedCallback(input); } ); - global::callback::touchUpdated.emplace_back( + global::callback::touchUpdated->emplace_back( [&](TouchInput input) -> bool { return gui.touchUpdatedCallback(input); } ); - global::callback::touchExit.emplace_back( + global::callback::touchExit->emplace_back( [&](TouchInput input) { gui.touchExitCallback(input); } diff --git a/modules/iswa/iswamodule.cpp b/modules/iswa/iswamodule.cpp index fa2869a174..59b222fb71 100644 --- a/modules/iswa/iswamodule.cpp +++ b/modules/iswa/iswamodule.cpp @@ -43,7 +43,7 @@ namespace openspace { IswaModule::IswaModule() : OpenSpaceModule(Name) { - global::callback::initialize.push_back([]() { + global::callback::initialize->push_back([]() { ZoneScopedN("IswaModule") IswaManager::initialize(); }); diff --git a/modules/server/servermodule.cpp b/modules/server/servermodule.cpp index 84910594da..a7a3df6ae3 100644 --- a/modules/server/servermodule.cpp +++ b/modules/server/servermodule.cpp @@ -73,7 +73,7 @@ ServerInterface* ServerModule::serverInterfaceByIdentifier(const std::string& id } void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) { - global::callback::preSync.emplace_back([this]() { + global::callback::preSync->emplace_back([this]() { ZoneScopedN("ServerModule") preSync(); diff --git a/modules/touch/touchmodule.cpp b/modules/touch/touchmodule.cpp index dc80b46fac..a5ace0268b 100644 --- a/modules/touch/touchmodule.cpp +++ b/modules/touch/touchmodule.cpp @@ -191,7 +191,7 @@ TouchModule::~TouchModule() { void TouchModule::internalInitialize(const ghoul::Dictionary& /*dictionary*/){ _ear.reset(new TuioEar()); - global::callback::initializeGL.push_back([&]() { + global::callback::initializeGL->push_back([&]() { LDEBUGC("TouchModule", "Initializing TouchMarker OpenGL"); _markers.initialize(); #ifdef WIN32 @@ -204,33 +204,33 @@ void TouchModule::internalInitialize(const ghoul::Dictionary& /*dictionary*/){ #endif }); - global::callback::deinitializeGL.push_back([&]() { + global::callback::deinitializeGL->push_back([&]() { LDEBUGC("TouchMarker", "Deinitialize TouchMarker OpenGL"); _markers.deinitialize(); }); // These are handled in UI thread, which (as of 20th dec 2019) is in main/rendering // thread so we don't need a mutex here - global::callback::touchDetected.push_back( + global::callback::touchDetected->push_back( [this](TouchInput i) { addTouchInput(i); return true; } ); - global::callback::touchUpdated.push_back( + global::callback::touchUpdated->push_back( [this](TouchInput i) { updateOrAddTouchInput(i); return true; } ); - global::callback::touchExit.push_back( + global::callback::touchExit->push_back( std::bind(&TouchModule::removeTouchInput, this, std::placeholders::_1) ); - global::callback::preSync.push_back([&]() { + global::callback::preSync->push_back([&]() { _touch.setCamera(global::navigationHandler->camera()); _touch.setFocusNode(global::navigationHandler->orbitalNavigator().anchorNode()); @@ -251,7 +251,7 @@ void TouchModule::internalInitialize(const ghoul::Dictionary& /*dictionary*/){ clearInputs(); }); - global::callback::render.push_back([&]() { + global::callback::render->push_back([&]() { _markers.render(_touchPoints); }); } diff --git a/modules/webbrowser/CMakeLists.txt b/modules/webbrowser/CMakeLists.txt index c914689fda..55f88c9be4 100644 --- a/modules/webbrowser/CMakeLists.txt +++ b/modules/webbrowser/CMakeLists.txt @@ -156,7 +156,7 @@ if (OS_MACOSX) # Helper executable target. add_executable(${CEF_HELPER_TARGET} MACOSX_BUNDLE ${WEBBROWSER_HELPER_SOURCES}) SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_HELPER_TARGET}) - add_cef_logical_target("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}") + # add_cef_logical_target("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}") add_dependencies(${CEF_HELPER_TARGET} libcef_dll_wrapper) target_link_libraries(${CEF_HELPER_TARGET} libcef_dll_wrapper ${CEF_STANDARD_LIBS}) set_target_properties(${CEF_HELPER_TARGET} PROPERTIES diff --git a/modules/webbrowser/cmake/webbrowser_helpers.cmake b/modules/webbrowser/cmake/webbrowser_helpers.cmake index ac082325ba..c9b6242ba8 100644 --- a/modules/webbrowser/cmake/webbrowser_helpers.cmake +++ b/modules/webbrowser/cmake/webbrowser_helpers.cmake @@ -77,7 +77,8 @@ function(run_cef_macosx_config CEF_ROOT module_path) add_dependencies(${CEF_TARGET} libcef_dll_wrapper "${CEF_HELPER_TARGET}") - target_link_libraries(${CEF_TARGET} PUBLIC libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS}) + # target_link_libraries(${CEF_TARGET} PUBLIC libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS}) + target_link_libraries(${CEF_TARGET} PUBLIC libcef_dll_wrapper ${CEF_STANDARD_LIBS}) set_target_properties(${CEF_TARGET} PROPERTIES RESOURCE "${WEBBROWSER_RESOURCES_SRCS}" MACOSX_BUNDLE_INFO_PLIST ${module_path}/mac/Info.plist diff --git a/modules/webbrowser/src/eventhandler.cpp b/modules/webbrowser/src/eventhandler.cpp index da9ca87185..aa65c1f64d 100644 --- a/modules/webbrowser/src/eventhandler.cpp +++ b/modules/webbrowser/src/eventhandler.cpp @@ -152,7 +152,7 @@ namespace { namespace openspace { void EventHandler::initialize() { - global::callback::character.emplace_back( + global::callback::character->emplace_back( [this](unsigned int charCode, KeyModifier mod) -> bool { if (_browserInstance) { return charCallback(charCode, mod); @@ -160,7 +160,7 @@ void EventHandler::initialize() { return false; } ); - global::callback::keyboard.emplace_back( + global::callback::keyboard->emplace_back( [this](Key key, KeyModifier mod, KeyAction action) -> bool { if (_browserInstance) { return keyboardCallback(key, mod, action); @@ -168,7 +168,7 @@ void EventHandler::initialize() { return false; } ); - global::callback::mousePosition.emplace_back( + global::callback::mousePosition->emplace_back( [this](double x, double y) -> bool { if (_browserInstance) { return mousePositionCallback(x, y); @@ -176,7 +176,7 @@ void EventHandler::initialize() { return false; } ); - global::callback::mouseButton.emplace_back( + global::callback::mouseButton->emplace_back( [this](MouseButton button, MouseAction action, KeyModifier mods) -> bool { if (_browserInstance) { return mouseButtonCallback(button, action, mods); @@ -184,7 +184,7 @@ void EventHandler::initialize() { return false; } ); - global::callback::mouseScrollWheel.emplace_back( + global::callback::mouseScrollWheel->emplace_back( [this](double x, double y) -> bool { if (_browserInstance) { const glm::ivec2 delta(x, y); @@ -194,7 +194,7 @@ void EventHandler::initialize() { } ); - global::callback::touchDetected.emplace_back( + global::callback::touchDetected->emplace_back( [&](TouchInput input) -> bool { if (!_browserInstance) { return false; @@ -236,7 +236,7 @@ void EventHandler::initialize() { } ); - global::callback::touchUpdated.emplace_back( + global::callback::touchUpdated->emplace_back( [&](TouchInput input) -> bool { if (!_browserInstance) { return false; @@ -278,7 +278,7 @@ void EventHandler::initialize() { } ); - global::callback::touchExit.emplace_back( + global::callback::touchExit->emplace_back( [&](TouchInput input) { if (!_browserInstance) { return; diff --git a/modules/webbrowser/webbrowsermodule.cpp b/modules/webbrowser/webbrowsermodule.cpp index 33a5fe0f46..cdcc85faeb 100644 --- a/modules/webbrowser/webbrowsermodule.cpp +++ b/modules/webbrowser/webbrowsermodule.cpp @@ -73,7 +73,7 @@ WebBrowserModule::WebBrowserModule() , _updateBrowserBetweenRenderables(UpdateBrowserBetweenRenderablesInfo, true) , _browserUpdateInterval(BrowserUpdateIntervalInfo, 1.f, 1.0f, 1000.f) { - global::callback::deinitialize.emplace_back([this]() { + global::callback::deinitialize->emplace_back([this]() { ZoneScopedN("WebBrowserModule") deinitialize(); diff --git a/src/engine/globals.cpp b/src/engine/globals.cpp index 1a008a11ca..2f5785d68e 100644 --- a/src/engine/globals.cpp +++ b/src/engine/globals.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -63,6 +64,12 @@ namespace openspace { namespace { + // This is kind of weird. Optimally, we would want to use the std::array also on + // non-Windows platforms but that causes some issues with nullptrs being thrown + // around and invalid accesses. Switching this to a std::vector with dynamic memory + // allocation works on Linux, but it fails on Windows in some SGCT function and on Mac + // in some random global randoms +#ifdef WIN32 constexpr const int TotalSize = sizeof(ghoul::fontrendering::FontManager) + sizeof(Dashboard) + @@ -96,6 +103,7 @@ namespace { sizeof(Profile); std::array DataStorage; +#endif // WIN32 } // namespace } // namespace openspace @@ -104,133 +112,262 @@ namespace openspace::global { void create() { ZoneScoped - std::byte* currentPos = DataStorage.data(); + callback::create(); +#ifdef WIN32 + std::fill(DataStorage.begin(), DataStorage.end(), std::byte(0)); + std::byte* currentPos = DataStorage.data(); +#endif // WIN32 + +#ifdef WIN32 fontManager = new (currentPos) ghoul::fontrendering::FontManager({ 1536, 1536, 1 }); ghoul_assert(fontManager, "No fontManager"); currentPos += sizeof(ghoul::fontrendering::FontManager); +#else // ^^^ WIN32 / !WIN32 vvv + fontManager = new ghoul::fontrendering::FontManager({ 1536, 1536, 1 }); +#endif // WIN32 +#ifdef WIN32 dashboard = new (currentPos) Dashboard; ghoul_assert(dashboard, "No dashboard"); currentPos += sizeof(Dashboard); +#else // ^^^ WIN32 / !WIN32 vvv + dashboard = new Dashboard; +#endif // WIN32 +#ifdef WIN32 deferredcasterManager = new (currentPos) DeferredcasterManager; ghoul_assert(deferredcasterManager, "No deferredcasterManager"); currentPos += sizeof(DeferredcasterManager); +#else // ^^^ WIN32 / !WIN32 vvv + deferredcasterManager = new DeferredcasterManager; +#endif // WIN32 +#ifdef WIN32 downloadManager = new (currentPos) DownloadManager; ghoul_assert(downloadManager, "No downloadManager"); currentPos += sizeof(DownloadManager); +#else // ^^^ WIN32 / !WIN32 vvv + downloadManager = new DownloadManager; +#endif // WIN32 +#ifdef WIN32 luaConsole = new (currentPos) LuaConsole; ghoul_assert(luaConsole, "No luaConsole"); currentPos += sizeof(LuaConsole); +#else // ^^^ WIN32 / !WIN32 vvv + luaConsole = new LuaConsole; +#endif // WIN32 +#ifdef WIN32 memoryManager = new (currentPos) MemoryManager; ghoul_assert(memoryManager, "No memoryManager"); currentPos += sizeof(MemoryManager); +#else // ^^^ WIN32 / !WIN32 vvv + memoryManager = new MemoryManager; +#endif // WIN32 +#ifdef WIN32 missionManager = new (currentPos) MissionManager; ghoul_assert(missionManager, "No missionManager"); currentPos += sizeof(MissionManager); +#else // ^^^ WIN32 / !WIN32 vvv + missionManager = new MissionManager; +#endif // WIN32 +#ifdef WIN32 moduleEngine = new (currentPos) ModuleEngine; ghoul_assert(moduleEngine, "No moduleEngine"); currentPos += sizeof(ModuleEngine); +#else // ^^^ WIN32 / !WIN32 vvv + moduleEngine = new ModuleEngine; +#endif // WIN32 +#ifdef WIN32 openSpaceEngine = new (currentPos) OpenSpaceEngine; ghoul_assert(openSpaceEngine, "No openSpaceEngine"); currentPos += sizeof(OpenSpaceEngine); +#else // ^^^ WIN32 / !WIN32 vvv + openSpaceEngine = new OpenSpaceEngine; +#endif // WIN32 +#ifdef WIN32 parallelPeer = new (currentPos) ParallelPeer; ghoul_assert(parallelPeer, "No parallelPeer"); currentPos += sizeof(ParallelPeer); +#else // ^^^ WIN32 / !WIN32 vvv + parallelPeer = new ParallelPeer; +#endif // WIN32 +#ifdef WIN32 raycasterManager = new (currentPos) RaycasterManager; ghoul_assert(raycasterManager, "No raycasterManager"); currentPos += sizeof(RaycasterManager); +#else // ^^^ WIN32 / !WIN32 vvv + raycasterManager = new RaycasterManager; +#endif // WIN32 +#ifdef WIN32 renderEngine = new (currentPos) RenderEngine; ghoul_assert(renderEngine, "No renderEngine"); currentPos += sizeof(RenderEngine); +#else // ^^^ WIN32 / !WIN32 vvv + renderEngine = new RenderEngine; +#endif // WIN32 +#ifdef WIN32 screenSpaceRenderables = new (currentPos) std::vector>; ghoul_assert(screenSpaceRenderables, "No screenSpaceRenderables"); currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + screenSpaceRenderables = new std::vector>; +#endif // WIN32 +#ifdef WIN32 syncEngine = new (currentPos) SyncEngine(4096); ghoul_assert(syncEngine, "No syncEngine"); currentPos += sizeof(SyncEngine); +#else // ^^^ WIN32 / !WIN32 vvv + syncEngine = new SyncEngine(4096); +#endif // WIN32 +#ifdef WIN32 timeManager = new (currentPos) TimeManager; ghoul_assert(timeManager, "No timeManager"); currentPos += sizeof(TimeManager); +#else // ^^^ WIN32 / !WIN32 vvv + timeManager = new TimeManager; +#endif // WIN32 +#ifdef WIN32 versionChecker = new (currentPos) VersionChecker; ghoul_assert(versionChecker, "No versionChecker"); currentPos += sizeof(VersionChecker); +#else + versionChecker = new VersionChecker; +#endif // WIN32 +#ifdef WIN32 virtualPropertyManager = new (currentPos) VirtualPropertyManager; ghoul_assert(virtualPropertyManager, "No virtualPropertyManager"); currentPos += sizeof(VirtualPropertyManager); +#else // ^^^ WIN32 / !WIN32 vvv + virtualPropertyManager = new VirtualPropertyManager; +#endif // WIN32 +#ifdef WIN32 windowDelegate = new (currentPos) WindowDelegate; ghoul_assert(windowDelegate, "No windowDelegate"); currentPos += sizeof(WindowDelegate); +#else // ^^^ WIN32 / !WIN32 vvv + windowDelegate = new WindowDelegate; +#endif // WIN32 +#ifdef WIN32 configuration = new (currentPos) configuration::Configuration; ghoul_assert(configuration, "No configuration"); currentPos += sizeof(configuration::Configuration); +#else // ^^^ WIN32 / !WIN32 vvv + configuration = new configuration::Configuration; +#endif // WIN32 +#ifdef WIN32 interactionMonitor = new (currentPos) interaction::InteractionMonitor; ghoul_assert(interactionMonitor, "No interactionMonitor"); currentPos += sizeof(interaction::InteractionMonitor); +#else // ^^^ WIN32 / !WIN32 vvv + interactionMonitor = new interaction::InteractionMonitor; +#endif // WIN32 +#ifdef WIN32 joystickInputStates = new (currentPos) interaction::JoystickInputStates; ghoul_assert(joystickInputStates, "No joystickInputStates"); currentPos += sizeof(interaction::JoystickInputStates); +#else // ^^^ WIN32 / !WIN32 vvv + joystickInputStates = new interaction::JoystickInputStates; +#endif // WIN32 +#ifdef WIN32 websocketInputStates = new (currentPos) interaction::WebsocketInputStates; ghoul_assert(websocketInputStates, "No websocketInputStates"); currentPos += sizeof(interaction::WebsocketInputStates); +#else // ^^^ WIN32 / !WIN32 vvv + websocketInputStates = new interaction::WebsocketInputStates; +#endif // WIN32 +#ifdef WIN32 keybindingManager = new (currentPos) interaction::KeybindingManager; ghoul_assert(keybindingManager, "No keybindingManager"); currentPos += sizeof(interaction::KeybindingManager); +#else // ^^^ WIN32 / !WIN32 vvv + keybindingManager = new interaction::KeybindingManager; +#endif // WIN32 +#ifdef WIN32 navigationHandler = new (currentPos) interaction::NavigationHandler; ghoul_assert(navigationHandler, "No navigationHandler"); currentPos += sizeof(interaction::NavigationHandler); +#else // ^^^ WIN32 / !WIN32 vvv + navigationHandler = new interaction::NavigationHandler; +#endif // WIN32 +#ifdef WIN32 sessionRecording = new (currentPos) interaction::SessionRecording(true); ghoul_assert(sessionRecording, "No sessionRecording"); currentPos += sizeof(interaction::SessionRecording); +#else // ^^^ WIN32 / !WIN32 vvv + sessionRecording = new interaction::SessionRecording(true); +#endif // WIN32 +#ifdef WIN32 shortcutManager = new (currentPos) interaction::ShortcutManager; ghoul_assert(shortcutManager, "No shortcutManager"); currentPos += sizeof(interaction::ShortcutManager); +#else // ^^^ WIN32 / !WIN32 vvv + shortcutManager = new interaction::ShortcutManager; +#endif // WIN32 +#ifdef WIN32 rootPropertyOwner = new (currentPos) properties::PropertyOwner({ "" }); ghoul_assert(rootPropertyOwner, "No rootPropertyOwner"); currentPos += sizeof(properties::PropertyOwner); +#else // ^^^ WIN32 / !WIN32 vvv + rootPropertyOwner = new properties::PropertyOwner({ "" }); +#endif // WIN32 +#ifdef WIN32 screenSpaceRootPropertyOwner = new (currentPos) properties::PropertyOwner({ "ScreenSpace" }); ghoul_assert(screenSpaceRootPropertyOwner, "No screenSpaceRootPropertyOwner"); currentPos += sizeof(properties::PropertyOwner); +#else // ^^^ WIN32 / !WIN32 vvv + screenSpaceRootPropertyOwner = new properties::PropertyOwner({ "ScreenSpace" }); +#endif // WIN32 +#ifdef WIN32 scriptEngine = new (currentPos) scripting::ScriptEngine; ghoul_assert(scriptEngine, "No scriptEngine"); currentPos += sizeof(scripting::ScriptEngine); +#else // ^^^ WIN32 / !WIN32 vvv + scriptEngine = new scripting::ScriptEngine; +#endif // WIN32 +#ifdef WIN32 scriptScheduler = new (currentPos) scripting::ScriptScheduler; ghoul_assert(scriptScheduler, "No scriptScheduler"); currentPos += sizeof(scripting::ScriptScheduler); +#else // ^^^ WIN32 / !WIN32 vvv + scriptScheduler = new scripting::ScriptScheduler; +#endif // WIN32 +#ifdef WIN32 profile = new (currentPos) Profile; ghoul_assert(profile, "No profile"); currentPos += sizeof(Profile); +#else // ^^^ WIN32 / !WIN32 vvv + profile = new Profile; +#endif // WIN32 } void initialize() { @@ -262,99 +399,223 @@ void initializeGL() { void destroy() { LDEBUGC("Globals", "Destroying 'Profile'"); +#ifdef WIN32 profile->~Profile(); +#else // ^^^ WIN32 / !WIN32 vvv + delete profile; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'ScriptScheduler'"); +#ifdef WIN32 scriptScheduler->~ScriptScheduler(); +#else // ^^^ WIN32 / !WIN32 vvv + delete scriptScheduler; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'ScriptEngine'"); +#ifdef WIN32 scriptEngine->~ScriptEngine(); +#else // ^^^ WIN32 / !WIN32 vvv + delete scriptEngine; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'ScreenSpace Root Owner'"); +#ifdef WIN32 screenSpaceRootPropertyOwner->~PropertyOwner(); +#else // ^^^ WIN32 / !WIN32 vvv + delete screenSpaceRootPropertyOwner; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'Root Owner'"); +#ifdef WIN32 rootPropertyOwner->~PropertyOwner(); +#else // ^^^ WIN32 / !WIN32 vvv + delete rootPropertyOwner; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'ShortcutManager'"); +#ifdef WIN32 shortcutManager->~ShortcutManager(); +#else // ^^^ WIN32 / !WIN32 vvv + delete shortcutManager; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'SessionRecording'"); +#ifdef WIN32 sessionRecording->~SessionRecording(); +#else // ^^^ WIN32 / !WIN32 vvv + delete sessionRecording; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'NavigationHandler'"); +#ifdef WIN32 navigationHandler->~NavigationHandler(); +#else // ^^^ WIN32 / !WIN32 vvv + delete navigationHandler; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'KeybindingManager'"); +#ifdef WIN32 keybindingManager->~KeybindingManager(); +#else // ^^^ WIN32 / !WIN32 vvv + delete keybindingManager; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'WebsocketInputStates'"); +#ifdef WIN32 websocketInputStates->~WebsocketInputStates(); +#else // ^^^ WIN32 / !WIN32 vvv + delete websocketInputStates; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'JoystickInputStates'"); +#ifdef WIN32 joystickInputStates->~JoystickInputStates(); +#else // ^^^ WIN32 / !WIN32 vvv + delete joystickInputStates; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'InteractionMonitor'"); +#ifdef WIN32 interactionMonitor->~InteractionMonitor(); +#else // ^^^ WIN32 / !WIN32 vvv + delete interactionMonitor; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'Configuration'"); +#ifdef WIN32 configuration->~Configuration(); +#else // ^^^ WIN32 / !WIN32 vvv + delete configuration; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'WindowDelegate'"); +#ifdef WIN32 windowDelegate->~WindowDelegate(); +#else // ^^^ WIN32 / !WIN32 vvv + delete windowDelegate; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'VirtualPropertyManager'"); +#ifdef WIN32 virtualPropertyManager->~VirtualPropertyManager(); +#else // ^^^ WIN32 / !WIN32 vvv + delete virtualPropertyManager; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'VersionChecker'"); +#ifdef WIN32 versionChecker->~VersionChecker(); +#else // ^^^ WIN32 / !WIN32 vvv + delete versionChecker; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'TimeManager'"); +#ifdef WIN32 timeManager->~TimeManager(); +#else // ^^^ WIN32 / !WIN32 vvv + delete timeManager; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'SyncEngine'"); +#ifdef WIN32 syncEngine->~SyncEngine(); +#else // ^^^ WIN32 / !WIN32 vvv + delete syncEngine; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'ScreenSpaceRenderables'"); - screenSpaceRenderables->~vector>(); +#ifdef WIN32 + screenSpaceRenderables->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete screenSpaceRenderables; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'RenderEngine'"); +#ifdef WIN32 renderEngine->~RenderEngine(); +#else // ^^^ WIN32 / !WIN32 vvv + delete renderEngine; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'RaycasterManager'"); +#ifdef WIN32 raycasterManager->~RaycasterManager(); +#else // ^^^ WIN32 / !WIN32 vvv + delete raycasterManager; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'ParallelPeer'"); +#ifdef WIN32 parallelPeer->~ParallelPeer(); +#else // ^^^ WIN32 / !WIN32 vvv + delete parallelPeer; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'OpenSpaceEngine'"); +#ifdef WIN32 openSpaceEngine->~OpenSpaceEngine(); +#else // ^^^ WIN32 / !WIN32 vvv + delete openSpaceEngine; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'ModuleEngine'"); +#ifdef WIN32 moduleEngine->~ModuleEngine(); +#else // ^^^ WIN32 / !WIN32 vvv + delete moduleEngine; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'MissionManager'"); +#ifdef WIN32 missionManager->~MissionManager(); +#else // ^^^ WIN32 / !WIN32 vvv + delete missionManager; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'MemoryManager'"); +#ifdef WIN32 memoryManager->~MemoryManager(); +#else // ^^^ WIN32 / !WIN32 vvv + delete memoryManager; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'LuaConsole'"); +#ifdef WIN32 luaConsole->~LuaConsole(); +#else // ^^^ WIN32 / !WIN32 vvv + delete luaConsole; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'DownloadManager'"); +#ifdef WIN32 downloadManager->~DownloadManager(); +#else // ^^^ WIN32 / !WIN32 vvv + delete downloadManager; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'DeferredcasterManager'"); +#ifdef WIN32 deferredcasterManager->~DeferredcasterManager(); +#else // ^^^ WIN32 / !WIN32 vvv + delete deferredcasterManager; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'Dashboard'"); +#ifdef WIN32 dashboard->~Dashboard(); +#else // ^^^ WIN32 / !WIN32 vvv + delete dashboard; +#endif // WIN32 LDEBUGC("Globals", "Destroying 'FontManager'"); +#ifdef WIN32 fontManager->~FontManager(); +#else // ^^^ WIN32 / !WIN32 vvv + delete fontManager; +#endif // WIN32 - std::fill(DataStorage.begin(), DataStorage.end(), std::byte(0)); + callback::destroy(); } void deinitialize() { diff --git a/src/engine/globalscallbacks.cpp b/src/engine/globalscallbacks.cpp index a6dba4bc19..e2953460eb 100644 --- a/src/engine/globalscallbacks.cpp +++ b/src/engine/globalscallbacks.cpp @@ -24,97 +24,295 @@ #include -namespace openspace::global::detail { - -std::vector>& gInitialize() { - static std::vector> g; - return g; -} - -std::vector>& gDeinitialize() { - static std::vector> g; - return g; -} - -std::vector>& gInitializeGL() { - static std::vector> g; - return g; -} - -std::vector>& gDeinitializeGL() { - static std::vector> g; - return g; -} - -std::vector>& gPreSync() { - static std::vector> g; - return g; -} - -std::vector>& gPostSyncPreDraw() { - static std::vector> g; - return g; -} - -std::vector>& gRender() { - static std::vector> g; - return g; -} - -std::vector>& gDraw2D() { - static std::vector> g; - return g; -} - -std::vector>& gPostDraw() { - static std::vector> g; - return g; -} - -std::vector>& gKeyboard() { - static std::vector> g; - return g; -} - -std::vector>& gCharacter() { - static std::vector> g; - return g; -} - -std::vector>& gMouseButton() { - static std::vector> g; - return g; -} - -std::vector>& gMousePosition() { - static std::vector> g; - return g; -} - -std::vector>& gMouseScrollWheel() { - static std::vector> g; - return g; -} - -std::vector>& gTouchDetected() { - static std::vector> g; - return g; -} - -std::vector>& gTouchUpdated() { - static std::vector> g; - return g; -} - -std::vector>& gTouchExit() { - static std::vector> g; - return g; -} - -} // namespace openspace::global::detail +#include +#include namespace openspace::global::callback { +namespace { + // Using the same mechanism as in the globals file +#ifdef WIN32 + constexpr const int TotalSize = + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>) + + sizeof(std::vector>); + + std::array DataStorage; +#endif // WIN32 + +} // namespace + +void create() { + ZoneScoped + +#ifdef WIN32 + std::fill(DataStorage.begin(), DataStorage.end(), std::byte(0)); + std::byte* currentPos = DataStorage.data(); +#endif // WIN32 + +#ifdef WIN32 + initialize = new (currentPos) std::vector>; + ghoul_assert(initialize, "No initialize"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + initialize = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + deinitialize = new (currentPos) std::vector>; + ghoul_assert(deinitialize, "No deinitialize"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + deinitialize = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + initializeGL = new (currentPos) std::vector>; + ghoul_assert(initializeGL, "No initializeGL"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + initializeGL = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + deinitializeGL = new (currentPos) std::vector>; + ghoul_assert(deinitializeGL, "No deinitializeGL"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + deinitializeGL = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + preSync = new (currentPos) std::vector>; + ghoul_assert(preSync, "No preSync"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + preSync = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + postSyncPreDraw = new (currentPos) std::vector>; + ghoul_assert(postSyncPreDraw, "No postSyncPreDraw"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + postSyncPreDraw = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + render = new (currentPos) std::vector>; + ghoul_assert(render, "No render"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + render = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + draw2D = new (currentPos) std::vector>; + ghoul_assert(draw2D, "No draw2D"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + draw2D = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + postDraw = new (currentPos) std::vector>; + ghoul_assert(postDraw, "No postDraw"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + postDraw = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + keyboard = + new (currentPos) std::vector>; + ghoul_assert(keyboard, "No keyboard"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + keyboard = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + character = + new (currentPos) std::vector>; + ghoul_assert(character, "No character"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + character = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + mouseButton = + new (currentPos) std::vector< + std::function + >; + ghoul_assert(mouseButton, "No mouseButton"); + currentPos += sizeof( + std::vector> + ); +#else // ^^^ WIN32 / !WIN32 vvv + mouseButton = + new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + mousePosition = new (currentPos) std::vector>; + ghoul_assert(mousePosition, "No mousePosition"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + mousePosition = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + mouseScrollWheel = new (currentPos) std::vector>; + ghoul_assert(mouseScrollWheel, "No mouseScrollWheel"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + mouseScrollWheel = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + touchDetected = new (currentPos) std::vector>; + ghoul_assert(touchDetected, "No touchDetected"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + touchDetected = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + touchUpdated = new (currentPos) std::vector>; + ghoul_assert(touchUpdated, "No touchUpdated"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + touchUpdated = new std::vector>; +#endif // WIN32 + +#ifdef WIN32 + touchExit = new (currentPos) std::vector>; + ghoul_assert(touchExit, "No touchExit"); + currentPos += sizeof(std::vector>); +#else // ^^^ WIN32 / !WIN32 vvv + touchExit = new std::vector>; +#endif // WIN32 +} + +void destroy() { +#ifdef WIN32 + touchExit->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete touchExit; +#endif // WIN32 + +#ifdef WIN32 + touchUpdated->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete touchUpdated; +#endif // WIN32 + +#ifdef WIN32 + touchDetected->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete touchDetected; +#endif // WIN32 + +#ifdef WIN32 + mouseScrollWheel->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete mouseScrollWheel; +#endif // WIN32 + +#ifdef WIN32 + mousePosition->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete mousePosition; +#endif // WIN32 + +#ifdef WIN32 + mouseButton->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete mouseButton; +#endif // WIN32 + +#ifdef WIN32 + character->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete character; +#endif // WIN32 + +#ifdef WIN32 + keyboard->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete keyboard; +#endif // WIN32 + +#ifdef WIN32 + postDraw->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete postDraw; +#endif // WIN32 + +#ifdef WIN32 + draw2D->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete draw2D; +#endif // WIN32 + +#ifdef WIN32 + render->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete render; +#endif // WIN32 + +#ifdef WIN32 + postSyncPreDraw->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete postSyncPreDraw; +#endif // WIN32 + +#ifdef WIN32 + preSync->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete preSync; +#endif // WIN32 + +#ifdef WIN32 + deinitializeGL->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete deinitializeGL; +#endif // WIN32 + +#ifdef WIN32 + initializeGL->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete initializeGL; +#endif // WIN32 + +#ifdef WIN32 + deinitialize->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete deinitialize; +#endif // WIN32 + +#ifdef WIN32 + initialize->~vector(); +#else // ^^^ WIN32 / !WIN32 vvv + delete initialize; +#endif // WIN32 +} + void(*webBrowserPerformanceHotfix)() = nullptr; } // namespace openspace::global::callback diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index cedd6501b7..d51f322e91 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -370,7 +370,7 @@ void OpenSpaceEngine::initialize() { global::renderEngine->initialize(); - for (const std::function& func : global::callback::initialize) { + for (const std::function& func : *global::callback::initialize) { ZoneScopedN("[Module] initialize") func(); @@ -663,7 +663,7 @@ void OpenSpaceEngine::initializeGL() { global::moduleEngine->initializeGL(); - for (const std::function& func : global::callback::initializeGL) { + for (const std::function& func : *global::callback::initializeGL) { ZoneScopedN("[Module] initializeGL") func(); } @@ -865,7 +865,7 @@ void OpenSpaceEngine::deinitialize() { LTRACE("OpenSpaceEngine::deinitialize(begin)"); - for (const std::function& func : global::callback::deinitialize) { + for (const std::function& func : *global::callback::deinitialize) { func(); } @@ -914,7 +914,7 @@ void OpenSpaceEngine::deinitializeGL() { global::openSpaceEngine->_scene = nullptr; global::renderEngine->setScene(nullptr); - for (const std::function& func : global::callback::deinitializeGL) { + for (const std::function& func : *global::callback::deinitializeGL) { func(); } @@ -1125,7 +1125,7 @@ void OpenSpaceEngine::preSynchronization() { global::interactionMonitor->updateActivityState(); } - for (const std::function& func : global::callback::preSync) { + for (const std::function& func : *global::callback::preSync) { ZoneScopedN("[Module] preSync") func(); @@ -1180,7 +1180,7 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { _scene->camera()->invalidateCache(); } - for (const std::function& func : global::callback::postSyncPreDraw) { + for (const std::function& func : *global::callback::postSyncPreDraw) { ZoneScopedN("[Module] postSyncPreDraw") func(); @@ -1226,7 +1226,7 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& view global::renderEngine->render(sceneMatrix, viewMatrix, projectionMatrix); - for (const std::function& func : global::callback::render) { + for (const std::function& func : *global::callback::render) { ZoneScopedN("[Module] render") func(); @@ -1251,7 +1251,7 @@ void OpenSpaceEngine::drawOverlays() { global::sessionRecording->render(); } - for (const std::function& func : global::callback::draw2D) { + for (const std::function& func : *global::callback::draw2D) { ZoneScopedN("[Module] draw2D") func(); @@ -1267,7 +1267,7 @@ void OpenSpaceEngine::postDraw() { global::renderEngine->postDraw(); - for (const std::function& func : global::callback::postDraw) { + for (const std::function& func : *global::callback::postDraw) { ZoneScopedN("[Module] postDraw") func(); @@ -1317,7 +1317,7 @@ void OpenSpaceEngine::keyboardCallback(Key key, KeyModifier mod, KeyAction actio } using F = std::function; - for (const F& func : global::callback::keyboard) { + for (const F& func : *global::callback::keyboard) { const bool isConsumed = func(key, mod, action); if (isConsumed) { return; @@ -1340,7 +1340,7 @@ void OpenSpaceEngine::charCallback(unsigned int codepoint, KeyModifier modifier) ZoneScoped using F = std::function; - for (const F& func : global::callback::character) { + for (const F& func : *global::callback::character) { bool isConsumed = func(codepoint, modifier); if (isConsumed) { return; @@ -1358,7 +1358,7 @@ void OpenSpaceEngine::mouseButtonCallback(MouseButton button, ZoneScoped using F = std::function; - for (const F& func : global::callback::mouseButton) { + for (const F& func : *global::callback::mouseButton) { bool isConsumed = func(button, action, mods); if (isConsumed) { // If the mouse was released, we still want to forward it to the navigation @@ -1390,7 +1390,7 @@ void OpenSpaceEngine::mousePositionCallback(double x, double y) { ZoneScoped using F = std::function; - for (const F& func : global::callback::mousePosition) { + for (const F& func : *global::callback::mousePosition) { func(x, y); } @@ -1404,7 +1404,7 @@ void OpenSpaceEngine::mouseScrollWheelCallback(double posX, double posY) { ZoneScoped using F = std::function; - for (const F& func : global::callback::mouseScrollWheel) { + for (const F& func : *global::callback::mouseScrollWheel) { bool isConsumed = func(posX, posY); if (isConsumed) { return; @@ -1419,7 +1419,7 @@ void OpenSpaceEngine::touchDetectionCallback(TouchInput input) { ZoneScoped using F = std::function; - for (const F& func : global::callback::touchDetected) { + for (const F& func : *global::callback::touchDetected) { bool isConsumed = func(input); if (isConsumed) { return; @@ -1431,7 +1431,7 @@ void OpenSpaceEngine::touchUpdateCallback(TouchInput input) { ZoneScoped using F = std::function; - for (const F& func : global::callback::touchUpdated) { + for (const F& func : *global::callback::touchUpdated) { bool isConsumed = func(input); if (isConsumed) { return; @@ -1443,7 +1443,7 @@ void OpenSpaceEngine::touchExitCallback(TouchInput input) { ZoneScoped using F = std::function; - for (const F& func : global::callback::touchExit) { + for (const F& func : *global::callback::touchExit) { func(input); } } diff --git a/src/interaction/touchbar.mm b/src/interaction/touchbar.mm index 644e199e29..077c553561 100644 --- a/src/interaction/touchbar.mm +++ b/src/interaction/touchbar.mm @@ -92,7 +92,7 @@ NSArray* focusIdentifiers; if ([identifier isEqualToString:pauseResultId]) { NSButton* button = [NSButton buttonWithTitle:NSLocalizedString( - (global::timeManager.isPaused() ? @"Resume" : @"Pause"), + (global::timeManager->isPaused() ? @"Resume" : @"Pause"), @"" ) target:self action:@selector(pauseResumeButtonAction:) @@ -172,14 +172,14 @@ NSArray* focusIdentifiers; } - (void)pauseResumeButtonAction:(id)sender { - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "openspace.time.togglePause();", scripting::ScriptEngine::RemoteScripting::Yes ); NSButton* button = static_cast(sender); // This check is inverted since the togglePause script has not run yet - [button setTitle: global::timeManager.isPaused() ? @"Pause" : @"Resume"]; + [button setTitle: global::timeManager->isPaused() ? @"Pause" : @"Resume"]; } - (void)focusObjectAction:(id)sender { @@ -195,7 +195,7 @@ NSArray* focusIdentifiers; "NavigationHandler.OrbitalNavigator.Aim", "NavigationHandler.OrbitalNavigator.RetargetAnchor" ); - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( str, scripting::ScriptEngine::RemoteScripting::Yes ); @@ -205,7 +205,7 @@ NSArray* focusIdentifiers; // Remove unused variable warning (void)sender; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "local isEnabled = openspace.getPropertyValue('Dashboard.IsEnabled');\ openspace.setPropertyValueSingle('Dashboard.IsEnabled', not isEnabled);\ openspace.setPropertyValueSingle('RenderEngine.ShowLog', not isEnabled);\ @@ -218,7 +218,7 @@ NSArray* focusIdentifiers; - (void)hideGuiAction:(id)sender { // Remove unused variable warning (void)sender; - global::scriptEngine.queueScript( + global::scriptEngine->queueScript( "local isEnabled = openspace.getPropertyValue('Modules.CefWebGui.Visible');\ openspace.setPropertyValueSingle('Modules.CefWebGui.Visible', not isEnabled);", scripting::ScriptEngine::RemoteScripting::No @@ -242,7 +242,7 @@ void showTouchbar() { [NSApplication sharedApplication].automaticCustomizeTouchBarMenuItemEnabled = YES; } - std::vector ns = global::renderEngine.scene()->allSceneGraphNodes(); + std::vector ns = global::renderEngine->scene()->allSceneGraphNodes(); std::sort( ns.begin(),