From 862bfd6947635ff47d1c26f54f621656a624c6a6 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 17 Feb 2015 10:36:18 +0100 Subject: [PATCH] Making most includes in openspaceengine into forward declarations --- include/openspace/engine/openspaceengine.h | 50 +++--- include/openspace/rendering/renderable.h | 5 +- openspace.cfg | 1 + src/engine/openspaceengine.cpp | 198 ++++++++++++--------- src/gui/gui.cpp | 15 +- src/interaction/interactionhandler.cpp | 48 ++--- src/interaction/keyboardcontroller.cpp | 10 +- src/interaction/luaconsole.cpp | 12 +- src/main.cpp | 3 +- src/query/query.cpp | 3 +- src/rendering/model/renderablemodel.cpp | 4 +- src/rendering/planets/renderableplanet.cpp | 14 +- src/rendering/renderablefov.cpp | 7 +- src/rendering/renderablepath.cpp | 8 +- src/rendering/renderablesphericalgrid.cpp | 15 +- src/rendering/renderablevolumegl.cpp | 10 +- src/rendering/renderengine.cpp | 15 +- src/scenegraph/scenegraph.cpp | 40 +++-- 18 files changed, 245 insertions(+), 213 deletions(-) diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index bc9e0a6c30..6bf67e37bd 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -25,19 +25,26 @@ #ifndef __OPENSPACEENGINE_H__ #define __OPENSPACEENGINE_H__ -#include -#include -#include -#include -#include -#include +#include +#include + +namespace ghoul { +namespace cmdparser { + class CommandlineParser; +} +} namespace openspace { -class GUI; -class SyncBuffer; +class ConfigurationManager; class LuaConsole; +class GUI; +class RenderEngine; +class SyncBuffer; +namespace interaction { + class InteractionHandler; +} namespace scripting { class ScriptEngine; } @@ -53,13 +60,14 @@ public: static bool findConfiguration(std::string& filename); - ConfigurationManager& configurationManager(); - interaction::InteractionHandler& interactionHandler(); - RenderEngine& renderEngine(); - scripting::ScriptEngine& scriptEngine(); - LuaConsole& console(); + // Guaranteed to return a valid pointer + ConfigurationManager* configurationManager(); + interaction::InteractionHandler* interactionHandler(); + RenderEngine* renderEngine(); + scripting::ScriptEngine* scriptEngine(); + LuaConsole* console(); - GUI& gui(); + GUI* gui(); // SGCT callbacks bool initializeGL(); @@ -91,13 +99,13 @@ private: static OpenSpaceEngine* _engine; - ConfigurationManager _configurationManager; - interaction::InteractionHandler _interactionHandler; - RenderEngine _renderEngine; - scripting::ScriptEngine _scriptEngine; - ghoul::cmdparser::CommandlineParser _commandlineParser; - LuaConsole _console; - GUI _gui; + ConfigurationManager* _configurationManager; + interaction::InteractionHandler* _interactionHandler; + RenderEngine* _renderEngine; + scripting::ScriptEngine* _scriptEngine; + ghoul::cmdparser::CommandlineParser* _commandlineParser; + LuaConsole* _console; + GUI* _gui; double _dt; SyncBuffer* _syncBuffer; diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index ab2b1b6d4d..2c6bac818a 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -25,15 +25,16 @@ #ifndef __RENDERABLE_H__ #define __RENDERABLE_H__ -// openspace #include #include #include +#include + +#include // Forward declare to minimize dependencies namespace ghoul { namespace opengl { - class ProgramObject; class Texture; } class Dictionary; diff --git a/openspace.cfg b/openspace.cfg index 3d29b863fc..1346a2d1a9 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -34,6 +34,7 @@ return { File = "${BASE_PATH}/LuaScripting.txt" }, SGCTConfig = "${SGCT}/single.xml", + --SGCTConfig = "${SGCT}/single_fisheye.xml", --SGCTConfig = "${SGCT}/two_nodes.xml", --SGCTConfig = "${SGCT}/single_sbs_stereo.xml", Scene = "${OPENSPACE_DATA}/scene/default.scene", diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 07246f784a..14e71a0bc7 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -24,10 +24,16 @@ #include +// sgct +#define SGCT_WINDOWS_INCLUDE +#include + +#include #include -#include +#include #include #include +#include #include #include #include @@ -39,18 +45,15 @@ #include #include + +#include +#include #include #include #include -#include #include #include -#include -#include - -// sgct -#define SGCT_WINDOWS_INCLUDE -#include +#include // std #include @@ -81,7 +84,13 @@ namespace openspace { OpenSpaceEngine* OpenSpaceEngine::_engine = nullptr; OpenSpaceEngine::OpenSpaceEngine(std::string programName) - : _commandlineParser(programName, true) + : _configurationManager(new ConfigurationManager) + , _interactionHandler(new interaction::InteractionHandler) + , _renderEngine(new RenderEngine) + , _scriptEngine(new scripting::ScriptEngine) + , _commandlineParser(new ghoul::cmdparser::CommandlineParser(programName, true)) + , _console(new LuaConsole) + , _gui(new GUI) , _syncBuffer(nullptr) { SpiceManager::initialize(); @@ -91,8 +100,17 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName) } OpenSpaceEngine::~OpenSpaceEngine() { - _gui.deinitializeGL(); - if(_syncBuffer) + _gui->deinitializeGL(); + + delete _configurationManager; + delete _interactionHandler; + delete _renderEngine; + delete _scriptEngine; + delete _commandlineParser; + delete _console; + delete _gui; + + if(_syncBuffer) delete _syncBuffer; _syncBuffer = nullptr; } @@ -135,8 +153,8 @@ bool OpenSpaceEngine::create(int argc, char** argv, // Parse commandline arguments std::vector remainingArguments; - _engine->_commandlineParser.setCommandLine(argc, argv, &sgctArguments); - const bool executeSuccess = _engine->_commandlineParser.execute(); + _engine->_commandlineParser->setCommandLine(argc, argv, &sgctArguments); + const bool executeSuccess = _engine->_commandlineParser->execute(); if (!executeSuccess) return false; @@ -156,7 +174,7 @@ bool OpenSpaceEngine::create(int argc, char** argv, // Loading configuration from disk LDEBUG("Loading configuration from disk"); - const bool configLoadSuccess = _engine->configurationManager().loadFromFile( + const bool configLoadSuccess = _engine->configurationManager()->loadFromFile( configurationFilePath); if (!configLoadSuccess) { LFATAL("Loading of configuration file '" << configurationFilePath << "' failed"); @@ -179,7 +197,7 @@ bool OpenSpaceEngine::create(int argc, char** argv, // Create the cachemanager FileSys.createCacheManager(absPath("${" + constants::configurationmanager::keyCache + "}")); - _engine->_console.initialize(); + _engine->_console->initialize(); // Register the provided shader directories ghoul::opengl::ShaderObject::addIncludePath("${SHADERS}"); @@ -189,7 +207,7 @@ bool OpenSpaceEngine::create(int argc, char** argv, // Determining SGCT configuration file LDEBUG("Determining SGCT configuration file"); std::string sgctConfigurationPath = _sgctDefaultConfigFile; - _engine->configurationManager().getValue( + _engine->configurationManager()->getValue( constants::configurationmanager::keyConfigSgct, sgctConfigurationPath); if (!commandlineArgumentPlaceholders.sgctConfigurationName.empty()) { @@ -208,7 +226,7 @@ bool OpenSpaceEngine::create(int argc, char** argv, } void OpenSpaceEngine::destroy() { - _engine->_console.deinitialize(); + _engine->_console->deinitialize(); delete _engine; ghoul::systemcapabilities::SystemCapabilities::deinitialize(); FactoryManager::deinitialize(); @@ -237,50 +255,50 @@ bool OpenSpaceEngine::initialize() { // Register Lua script functions LDEBUG("Registering Lua libraries"); - _scriptEngine.addLibrary(RenderEngine::luaLibrary()); - _scriptEngine.addLibrary(SceneGraph::luaLibrary()); - _scriptEngine.addLibrary(Time::luaLibrary()); - _scriptEngine.addLibrary(interaction::InteractionHandler::luaLibrary()); - _scriptEngine.addLibrary(LuaConsole::luaLibrary()); - _scriptEngine.addLibrary(GUI::luaLibrary()); + _scriptEngine->addLibrary(RenderEngine::luaLibrary()); + _scriptEngine->addLibrary(SceneGraph::luaLibrary()); + _scriptEngine->addLibrary(Time::luaLibrary()); + _scriptEngine->addLibrary(interaction::InteractionHandler::luaLibrary()); + _scriptEngine->addLibrary(LuaConsole::luaLibrary()); + _scriptEngine->addLibrary(GUI::luaLibrary()); // TODO: Maybe move all scenegraph and renderengine stuff to initializeGL - scriptEngine().initialize(); + scriptEngine()->initialize(); // If a LuaDocumentationFile was specified, generate it now using constants::configurationmanager::keyLuaDocumentationType; using constants::configurationmanager::keyLuaDocumentationFile; - const bool hasType = configurationManager().hasKey(keyLuaDocumentationType); - const bool hasFile = configurationManager().hasKey(keyLuaDocumentationFile); + const bool hasType = configurationManager()->hasKey(keyLuaDocumentationType); + const bool hasFile = configurationManager()->hasKey(keyLuaDocumentationFile); if (hasType && hasFile) { std::string luaDocumentationType; - configurationManager().getValue(keyLuaDocumentationType, luaDocumentationType); + configurationManager()->getValue(keyLuaDocumentationType, luaDocumentationType); std::string luaDocumentationFile; - configurationManager().getValue(keyLuaDocumentationFile, luaDocumentationFile); + configurationManager()->getValue(keyLuaDocumentationFile, luaDocumentationFile); luaDocumentationFile = absPath(luaDocumentationFile); - _scriptEngine.writeDocumentation(luaDocumentationFile, luaDocumentationType); + _scriptEngine->writeDocumentation(luaDocumentationFile, luaDocumentationType); } // Load scenegraph SceneGraph* sceneGraph = new SceneGraph; - _renderEngine.setSceneGraph(sceneGraph); + _renderEngine->setSceneGraph(sceneGraph); // initialize the RenderEngine - _renderEngine.initialize(); + _renderEngine->initialize(); sceneGraph->initialize(); std::string sceneDescriptionPath; - success = configurationManager().getValue( + success = configurationManager()->getValue( constants::configurationmanager::keyConfigScene, sceneDescriptionPath); if (success) sceneGraph->scheduleLoadSceneFile(sceneDescriptionPath); - _interactionHandler.setKeyboardController(new interaction::KeyboardControllerFixed); + _interactionHandler->setKeyboardController(new interaction::KeyboardControllerFixed); //_interactionHandler.setKeyboardController(new interaction::KeyboardControllerLua); //_interactionHandler.setMouseController(new interaction::TrackballMouseController); - _interactionHandler.setMouseController(new interaction::OrbitalMouseController); + _interactionHandler->setMouseController(new interaction::OrbitalMouseController); // Run start up scripts runStartupScripts(); @@ -288,7 +306,7 @@ bool OpenSpaceEngine::initialize() { // Load a light and a monospaced font loadFonts(); - _gui.initialize(); + _gui->initialize(); return true; } @@ -314,14 +332,14 @@ bool OpenSpaceEngine::gatherCommandlineArguments() { CommandlineCommand* configurationFileCommand = new SingleCommand( &commandlineArgumentPlaceholders.configurationName, "-config", "-c", "Provides the path to the OpenSpace configuration file"); - _commandlineParser.addCommand(configurationFileCommand); + _commandlineParser->addCommand(configurationFileCommand); commandlineArgumentPlaceholders.sgctConfigurationName = ""; CommandlineCommand* sgctConfigFileCommand = new SingleCommand( &commandlineArgumentPlaceholders.sgctConfigurationName, "-sgct", "-s", "Provides the path to the SGCT configuration file, overriding the value set in" "the OpenSpace configuration file"); - _commandlineParser.addCommand(sgctConfigFileCommand); + _commandlineParser->addCommand(sgctConfigFileCommand); return true; } @@ -354,7 +372,7 @@ bool OpenSpaceEngine::loadSpiceKernels() { // Load time kernel using constants::configurationmanager::keySpiceTimeKernel; std::string timeKernel; - bool success = configurationManager().getValue(keySpiceTimeKernel, timeKernel); + bool success = configurationManager()->getValue(keySpiceTimeKernel, timeKernel); if (!success) { LERROR("Configuration file does not contain a '" << keySpiceTimeKernel << "'"); return false; @@ -369,7 +387,7 @@ bool OpenSpaceEngine::loadSpiceKernels() { // Load SPICE leap second kernel using constants::configurationmanager::keySpiceLeapsecondKernel; std::string leapSecondKernel; - success = configurationManager().getValue(keySpiceLeapsecondKernel, leapSecondKernel); + success = configurationManager()->getValue(keySpiceLeapsecondKernel, leapSecondKernel); if (!success) { LERROR("Configuration file does not have a '" << keySpiceLeapsecondKernel << "'"); return false; @@ -384,7 +402,7 @@ bool OpenSpaceEngine::loadSpiceKernels() { void OpenSpaceEngine::runStartupScripts() { ghoul::Dictionary scripts; - configurationManager().getValue( + configurationManager()->getValue( constants::configurationmanager::keyStartupScript, scripts); for (size_t i = 1; i <= scripts.size(); ++i) { std::stringstream stream; @@ -400,7 +418,7 @@ void OpenSpaceEngine::runStartupScripts() { std::string scriptPath; scripts.getValue(key, scriptPath); std::string&& absoluteScriptPath = absPath(scriptPath); - _engine->scriptEngine().runScriptFile(absoluteScriptPath); + _engine->scriptEngine()->runScriptFile(absoluteScriptPath); } } @@ -408,7 +426,7 @@ void OpenSpaceEngine::loadFonts() { sgct_text::FontManager::FontPath local = sgct_text::FontManager::FontPath::FontPath_Local; ghoul::Dictionary fonts; - configurationManager().getValue(constants::configurationmanager::keyFonts, fonts); + configurationManager()->getValue(constants::configurationmanager::keyFonts, fonts); for (const std::string& key : fonts.keys()) { std::string font; @@ -428,15 +446,15 @@ void OpenSpaceEngine::configureLogging() { using constants::configurationmanager::keyLogLevel; using constants::configurationmanager::keyLogs; - if (configurationManager().hasKeyAndValue(keyLogLevel)) { + if (configurationManager()->hasKeyAndValue(keyLogLevel)) { using constants::configurationmanager::keyLogLevel; using constants::configurationmanager::keyLogImmediateFlush; std::string logLevel; - configurationManager().getValue(keyLogLevel, logLevel); + configurationManager()->getValue(keyLogLevel, logLevel); bool immediateFlush = false; - configurationManager().getValue(keyLogImmediateFlush, immediateFlush); + configurationManager()->getValue(keyLogImmediateFlush, immediateFlush); LogManager::LogLevel level = LogManager::levelFromString(logLevel); LogManager::deinitialize(); @@ -444,9 +462,9 @@ void OpenSpaceEngine::configureLogging() { LogMgr.addLog(new ConsoleLog); } - if (configurationManager().hasKeyAndValue(keyLogs)) { + if (configurationManager()->hasKeyAndValue(keyLogs)) { ghoul::Dictionary logs; - configurationManager().getValue(keyLogs, logs); + configurationManager()->getValue(keyLogs, logs); for (size_t i = 1; i <= logs.size(); ++i) { ghoul::Dictionary logInfo; @@ -460,33 +478,39 @@ void OpenSpaceEngine::configureLogging() { } } -ConfigurationManager& OpenSpaceEngine::configurationManager() { +ConfigurationManager* OpenSpaceEngine::configurationManager() { + ghoul_assert(_configurationManager != nullptr, "ConfigurationManager is nullptr"); return _configurationManager; } -interaction::InteractionHandler& OpenSpaceEngine::interactionHandler() { +interaction::InteractionHandler* OpenSpaceEngine::interactionHandler() { + ghoul_assert(_interactionHandler != nullptr, "InteractionHandler is nullptr"); return _interactionHandler; } -RenderEngine& OpenSpaceEngine::renderEngine() { +RenderEngine* OpenSpaceEngine::renderEngine() { + ghoul_assert(_renderEngine != nullptr, "RenderEngine is nullptr"); return _renderEngine; } -ScriptEngine& OpenSpaceEngine::scriptEngine() { +ScriptEngine* OpenSpaceEngine::scriptEngine() { + ghoul_assert(_scriptEngine != nullptr, "ScriptEngine is nullptr"); return _scriptEngine; } -LuaConsole& OpenSpaceEngine::console() { +LuaConsole* OpenSpaceEngine::console() { + ghoul_assert(_console != nullptr, "LuaConsole is nullptr"); return _console; } -GUI& OpenSpaceEngine::gui() { +GUI* OpenSpaceEngine::gui() { + ghoul_assert(_gui != nullptr, "GUI is nullptr"); return _gui; } bool OpenSpaceEngine::initializeGL() { - bool success = _renderEngine.initializeGL(); - _gui.initializeGL(); + bool success = _renderEngine->initializeGL(); + _gui->initializeGL(); return success; } @@ -495,19 +519,19 @@ void OpenSpaceEngine::preSynchronization() { if (sgct::Engine::instance()->isMaster()) { const double dt = sgct::Engine::instance()->getDt(); - _interactionHandler.update(dt); + _interactionHandler->update(dt); //_interactionHandler.lockControls(); Time::ref().advanceTime(dt); - _renderEngine.preSynchronization(); + _renderEngine->preSynchronization(); } } void OpenSpaceEngine::postSynchronizationPreDraw() { - _renderEngine.postSynchronizationPreDraw(); + _renderEngine->postSynchronizationPreDraw(); - if (sgct::Engine::instance()->isMaster() && _gui.isEnabled()) { + if (sgct::Engine::instance()->isMaster() && _gui->isEnabled()) { double posX, posY; sgct::Engine::instance()->getMousePos(0, &posX, &posY); @@ -519,22 +543,22 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { bool buttons[2] = { button0 != 0, button1 != 0 }; double dt = std::max(sgct::Engine::instance()->getDt(), 1.0/60.0); - _gui.startFrame(static_cast(dt), glm::vec2(glm::ivec2(x,y)), glm::vec2(posX, posY), buttons); + _gui->startFrame(static_cast(dt), glm::vec2(glm::ivec2(x,y)), glm::vec2(posX, posY), buttons); } } void OpenSpaceEngine::render() { - _renderEngine.render(); + _renderEngine->render(); if (sgct::Engine::instance()->isMaster()) { // If currently writing a command, render it to screen sgct::SGCTWindow* w = sgct::Engine::instance()->getActiveWindowPtr(); - if (sgct::Engine::instance()->isMaster() && !w->isUsingFisheyeRendering() && _console.isVisible()) { - _console.render(); + if (sgct::Engine::instance()->isMaster() && !w->isUsingFisheyeRendering() && _console->isVisible()) { + _console->render(); } - if (_gui.isEnabled()) - _gui.endFrame(); + if (_gui->isEnabled()) + _gui->endFrame(); } } @@ -542,76 +566,76 @@ void OpenSpaceEngine::postDraw() { if (sgct::Engine::instance()->isMaster()) //_interactionHandler.unlockControls(); - _renderEngine.postDraw(); + _renderEngine->postDraw(); } void OpenSpaceEngine::keyboardCallback(int key, int action) { if (sgct::Engine::instance()->isMaster()) { - if (_gui.isEnabled()) { - bool isConsumed = _gui.keyCallback(key, action); + if (_gui->isEnabled()) { + bool isConsumed = _gui->keyCallback(key, action); if (isConsumed) return; } - if (key == _console.commandInputButton() && (action == SGCT_PRESS || action == SGCT_REPEAT)) - _console.toggleVisibility(); + if (key == _console->commandInputButton() && (action == SGCT_PRESS || action == SGCT_REPEAT)) + _console->toggleVisibility(); - if (!_console.isVisible()) { - _interactionHandler.keyboardCallback(key, action); + if (!_console->isVisible()) { + _interactionHandler->keyboardCallback(key, action); } else { - _console.keyboardCallback(key, action); + _console->keyboardCallback(key, action); } } } void OpenSpaceEngine::charCallback(unsigned int codepoint) { if (sgct::Engine::instance()->isMaster()) { - if (_gui.isEnabled()) { - bool isConsumed = _gui.charCallback(codepoint); + if (_gui->isEnabled()) { + bool isConsumed = _gui->charCallback(codepoint); if (isConsumed) return; } - if (_console.isVisible()) { - _console.charCallback(codepoint); + if (_console->isVisible()) { + _console->charCallback(codepoint); } } } void OpenSpaceEngine::mouseButtonCallback(int key, int action) { if (sgct::Engine::instance()->isMaster()) { - if (_gui.isEnabled()) { - bool isConsumed = _gui.mouseButtonCallback(key, action); + if (_gui->isEnabled()) { + bool isConsumed = _gui->mouseButtonCallback(key, action); if (isConsumed && action != SGCT_RELEASE) return; } - _interactionHandler.mouseButtonCallback(key, action); + _interactionHandler->mouseButtonCallback(key, action); } } void OpenSpaceEngine::mousePositionCallback(int x, int y) { if (sgct::Engine::instance()->isMaster()) { - _interactionHandler.mousePositionCallback(x, y); + _interactionHandler->mousePositionCallback(x, y); } } void OpenSpaceEngine::mouseScrollWheelCallback(int pos) { if (sgct::Engine::instance()->isMaster()) { - if (_gui.isEnabled()) { - bool isConsumed = _gui.mouseWheelCallback(pos); + if (_gui->isEnabled()) { + bool isConsumed = _gui->mouseWheelCallback(pos); if (isConsumed) return; } - _interactionHandler.mouseScrollWheelCallback(pos); + _interactionHandler->mouseScrollWheelCallback(pos); } } void OpenSpaceEngine::encode() { if (_syncBuffer) { - _renderEngine.serialize(_syncBuffer); + _renderEngine->serialize(_syncBuffer); _syncBuffer->write(); } } @@ -619,7 +643,7 @@ void OpenSpaceEngine::encode() { void OpenSpaceEngine::decode() { if (_syncBuffer) { _syncBuffer->read(); - _renderEngine.deserialize(_syncBuffer); + _renderEngine->deserialize(_syncBuffer); } } @@ -636,7 +660,7 @@ void OpenSpaceEngine::externalControlCallback(const char* receivedChars, { std::string script = std::string(receivedChars + 1); LINFO("Received Lua Script: '" << script << "'"); - _scriptEngine.runScript(script); + _scriptEngine->runScript(script); } } } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 38ee4844b4..62b44a5f1d 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -24,8 +24,14 @@ #include +// This needs to be included first due to Windows.h / winsock2.h complications +#define SGCT_WINDOWS_INCLUDE +#include + + #include #include +#include #include #include @@ -45,7 +51,6 @@ #include #include -#include #define STB_IMAGE_IMPLEMENTATION #include @@ -572,7 +577,7 @@ void GUI::renderPerformanceWindow() { }; ImGui::Begin("Performance", &_showPerformanceWindow); - if (OsEng.renderEngine().doesPerformanceMeasurements() && + if (OsEng.renderEngine()->doesPerformanceMeasurements() && ghoul::SharedMemory::exists(RenderEngine::PerformanceMeasurementSharedData)) { ImGui::SliderFloat2("Min values, max Value", _minMaxValues, 0.f, 10000.f); @@ -618,7 +623,7 @@ int show(lua_State* L) { if (nArguments != 0) return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - OsEng.gui().setEnabled(true); + OsEng.gui()->setEnabled(true); return 0; } @@ -632,7 +637,7 @@ int hide(lua_State* L) { if (nArguments != 0) return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - OsEng.gui().setEnabled(false); + OsEng.gui()->setEnabled(false); return 0; } @@ -646,7 +651,7 @@ int toggle(lua_State* L) { if (nArguments != 0) return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - OsEng.gui().setEnabled(!OsEng.gui().isEnabled()); + OsEng.gui()->setEnabled(!OsEng.gui()->isEnabled()); return 0; } diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp index ba00fda1ee..54fa6852a1 100644 --- a/src/interaction/interactionhandler.cpp +++ b/src/interaction/interactionhandler.cpp @@ -22,35 +22,15 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -//<<<<<<< HEAD -//// open space includes #include // #include -//#include -//#include -//#include -//#include -#include -//#include -//#include -//#include -#include -// -//// ghoul -#include -// -//// other -//#include -//#include -// -//// std includes -//#include -//#include -// - #include +#include +#include +#include +#include #include namespace { @@ -231,7 +211,7 @@ int setOrigin(lua_State* L) { return 0; } - OsEng.interactionHandler().setFocusNode(node); + OsEng.interactionHandler()->setFocusNode(node); return 0; } @@ -264,7 +244,7 @@ int bindKey(lua_State* L) { } - OsEng.interactionHandler().bindKey(iKey, command); + OsEng.interactionHandler()->bindKey(iKey, command); return 0; } @@ -282,7 +262,7 @@ int clearKeys(lua_State* L) { if (nArguments != 0) return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - OsEng.interactionHandler().resetKeyBindings(); + OsEng.interactionHandler()->resetKeyBindings(); return 0; } @@ -297,7 +277,7 @@ int dt(lua_State* L) { if (nArguments != 0) return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - lua_pushnumber(L,OsEng.interactionHandler().deltaTime()); + lua_pushnumber(L,OsEng.interactionHandler()->deltaTime()); return 1; } @@ -314,7 +294,7 @@ int distance(lua_State* L) { double d1 = luaL_checknumber(L, -2); double d2 = luaL_checknumber(L, -1); PowerScaledScalar dist(static_cast(d1), static_cast(d2)); - OsEng.interactionHandler().distanceDelta(dist); + OsEng.interactionHandler()->distanceDelta(dist); return 0; } @@ -852,21 +832,21 @@ void InteractionHandler::keyboardCallback(int key, int action) { rotateDelta(rot); } if (key == SGCT_KEY_KP_SUBTRACT) { - glm::vec2 s = OsEng.renderEngine().camera()->scaling(); + glm::vec2 s = OsEng.renderEngine()->camera()->scaling(); s[1] -= 0.5f; - OsEng.renderEngine().camera()->setScaling(s); + OsEng.renderEngine()->camera()->setScaling(s); } if (key == SGCT_KEY_KP_ADD) { - glm::vec2 s = OsEng.renderEngine().camera()->scaling(); + glm::vec2 s = OsEng.renderEngine()->camera()->scaling(); s[1] += 0.5f; - OsEng.renderEngine().camera()->setScaling(s); + OsEng.renderEngine()->camera()->setScaling(s); } // iterate over key bindings _validKeyLua = true; auto ret = _keyLua.equal_range(key); for (auto it = ret.first; it != ret.second; ++it) { - OsEng.scriptEngine().runScript(it->second); + OsEng.scriptEngine()->runScript(it->second); if (!_validKeyLua) { break; } diff --git a/src/interaction/keyboardcontroller.cpp b/src/interaction/keyboardcontroller.cpp index f3279d4871..2e17e737eb 100644 --- a/src/interaction/keyboardcontroller.cpp +++ b/src/interaction/keyboardcontroller.cpp @@ -24,7 +24,9 @@ #include +#include #include +#include #include #include @@ -114,14 +116,14 @@ void KeyboardControllerFixed::keyPressed(KeyAction action, Key key, KeyModifier } if (key == Key::KeypadSubtract) { - glm::vec2 s = OsEng.renderEngine().camera()->scaling(); + glm::vec2 s = OsEng.renderEngine()->camera()->scaling(); s[1] -= 0.5; - OsEng.renderEngine().camera()->setScaling(s); + OsEng.renderEngine()->camera()->setScaling(s); } if (key == Key::KeypadAdd) { - glm::vec2 s = OsEng.renderEngine().camera()->scaling(); + glm::vec2 s = OsEng.renderEngine()->camera()->scaling(); s[1] += 0.5; - OsEng.renderEngine().camera()->setScaling(s); + OsEng.renderEngine()->camera()->setScaling(s); } } /* diff --git a/src/interaction/luaconsole.cpp b/src/interaction/luaconsole.cpp index 9fb510221c..c7635b4482 100644 --- a/src/interaction/luaconsole.cpp +++ b/src/interaction/luaconsole.cpp @@ -58,7 +58,7 @@ int show(lua_State* L) { if (nArguments != 0) return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - OsEng.console().setVisible(true); + OsEng.console()->setVisible(true); return 0; } @@ -72,7 +72,7 @@ int hide(lua_State* L) { if (nArguments != 0) return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - OsEng.console().setVisible(false); + OsEng.console()->setVisible(false); return 0; } @@ -86,7 +86,7 @@ int toggle(lua_State* L) { if (nArguments != 0) return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - OsEng.console().toggleVisibility(); + OsEng.console()->toggleVisibility(); return 0; } @@ -116,7 +116,7 @@ void LuaConsole::initialize() { int64_t nCommands; file.read(reinterpret_cast(&nCommands), sizeof(int64_t)); - for (size_t i = 0; i < nCommands; ++i) { + for (int64_t i = 0; i < nCommands; ++i) { int64_t length; file.read(reinterpret_cast(&length), sizeof(int64_t)); char* tmp = new char[length + 1]; @@ -217,7 +217,7 @@ void LuaConsole::keyboardCallback(int key, int action) { // ENTER == run lua script else { if (_commands.at(_activeCommand) != "") { - OsEng.scriptEngine().runScript(_commands.at(_activeCommand)); + OsEng.scriptEngine()->runScript(_commands.at(_activeCommand)); if (!_commandsHistory.empty() && _commands.at(_activeCommand) != _commandsHistory.at(_commandsHistory.size() - 1)) _commandsHistory.push_back(_commands.at(_activeCommand)); @@ -243,7 +243,7 @@ void LuaConsole::keyboardCallback(int key, int action) { // find the value before the one that was previously found if (_autoCompleteInfo.lastAutoCompleteIndex != NoAutoComplete && modifierShift) _autoCompleteInfo.lastAutoCompleteIndex -= 2; - std::vector allCommands = OsEng.scriptEngine().allLuaFunctions(); + std::vector allCommands = OsEng.scriptEngine()->allLuaFunctions(); std::sort(allCommands.begin(), allCommands.end()); std::string currentCommand = _commands.at(_activeCommand); diff --git a/src/main.cpp b/src/main.cpp index a3513a6255..2f7c745809 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,10 +22,9 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -// open space includes #include -// sgct includes +#include #include sgct::Engine* _sgctEngine; diff --git a/src/query/query.cpp b/src/query/query.cpp index b75ec2b61b..1208c8ad07 100644 --- a/src/query/query.cpp +++ b/src/query/query.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -37,7 +38,7 @@ namespace { SceneGraph* sceneGraph() { - return OsEng.renderEngine().sceneGraph(); + return OsEng.renderEngine()->sceneGraph(); } SceneGraphNode* sceneGraphNode(const std::string& name) diff --git a/src/rendering/model/renderablemodel.cpp b/src/rendering/model/renderablemodel.cpp index 850449e7ea..34dc671fd6 100644 --- a/src/rendering/model/renderablemodel.cpp +++ b/src/rendering/model/renderablemodel.cpp @@ -29,7 +29,7 @@ #include #include #include - +#include #include #include @@ -99,7 +99,7 @@ bool RenderableModel::initialize(){ bool completeSuccess = true; if (_programObject == nullptr) completeSuccess - &= OsEng.ref().configurationManager().getValue("pscShader", _programObject); + &= OsEng.ref().configurationManager()->getValue("pscShader", _programObject); loadTexture(); diff --git a/src/rendering/planets/renderableplanet.cpp b/src/rendering/planets/renderableplanet.cpp index f3807c5171..0a0722e43e 100644 --- a/src/rendering/planets/renderableplanet.cpp +++ b/src/rendering/planets/renderableplanet.cpp @@ -24,18 +24,20 @@ // open space includes #include + +#include +#include +#include #include #include #include -#include -#include +#include +#include +#include #include #include #include -#include -#include -#include #include @@ -103,7 +105,7 @@ RenderablePlanet::~RenderablePlanet() { bool RenderablePlanet::initialize() { if (_programObject == nullptr) - OsEng.ref().configurationManager().getValue("pscShader", _programObject); + OsEng.ref().configurationManager()->getValue("pscShader", _programObject); loadTexture(); _geometry->initialize(this); diff --git a/src/rendering/renderablefov.cpp b/src/rendering/renderablefov.cpp index 12f9615d26..01ed52fe91 100644 --- a/src/rendering/renderablefov.cpp +++ b/src/rendering/renderablefov.cpp @@ -21,15 +21,18 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ + #include + +#include #include #include +#include #include #include #include -#include #include #include @@ -127,7 +130,7 @@ void RenderableFov::sendToGPU(){ bool RenderableFov::initialize(){ bool completeSuccess = true; if (_programObject == nullptr) - completeSuccess &= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject); + completeSuccess &= OsEng.ref().configurationManager()->getValue("EphemerisProgram", _programObject); SpiceManager::ref().getETfromDate("2007 feb 26 20:00:00", _startTrail); diff --git a/src/rendering/renderablepath.cpp b/src/rendering/renderablepath.cpp index 9cd922930f..7baf6309fe 100644 --- a/src/rendering/renderablepath.cpp +++ b/src/rendering/renderablepath.cpp @@ -21,17 +21,21 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ + #include + +#include #include #include +#include #include #include #include -#include #include #include + namespace { const std::string _loggerCat = "RenderablePath"; //constants @@ -170,7 +174,7 @@ bool RenderablePath::initialize(){ bool completeSuccess = true; if (_programObject == nullptr) completeSuccess - &= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject); + &= OsEng.ref().configurationManager()->getValue("EphemerisProgram", _programObject); // Initialize and upload to graphics card glGenVertexArrays(1, &_vaoID); diff --git a/src/rendering/renderablesphericalgrid.cpp b/src/rendering/renderablesphericalgrid.cpp index 1758e4ffcd..2d5a38f9cf 100644 --- a/src/rendering/renderablesphericalgrid.cpp +++ b/src/rendering/renderablesphericalgrid.cpp @@ -22,18 +22,15 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -//standard includes. -#include -#include -#define _USE_MATH_DEFINES -#include - -#include - #include + +#include +#include #include #include +#define _USE_MATH_DEFINES +#include namespace { const std::string _loggerCat = "RenderableSphericalGrid"; @@ -155,7 +152,7 @@ bool RenderableSphericalGrid::deinitialize(){ bool RenderableSphericalGrid::initialize(){ bool completeSuccess = true; if (_gridProgram == nullptr) - completeSuccess &= OsEng.ref().configurationManager().getValue("GridProgram", _gridProgram); + completeSuccess &= OsEng.ref().configurationManager()->getValue("GridProgram", _gridProgram); // Initialize and upload to graphics card glGenVertexArrays(1, &_vaoID); diff --git a/src/rendering/renderablevolumegl.cpp b/src/rendering/renderablevolumegl.cpp index ec7109134b..f5e7a9db82 100644 --- a/src/rendering/renderablevolumegl.cpp +++ b/src/rendering/renderablevolumegl.cpp @@ -25,7 +25,9 @@ #include #include +#include #include +#include #include #include @@ -178,13 +180,13 @@ bool RenderableVolumeGL::initialize() { if(_filename != "") { _volume = loadVolume(_filename, _hintsDictionary); _volume->uploadTexture(); - OsEng.renderEngine().abuffer()->addVolume(_volumeName, _volume); + OsEng.renderEngine()->abuffer()->addVolume(_volumeName, _volume); } if(_transferFunctionPath != "") { _transferFunction = loadTransferFunction(_transferFunctionPath); _transferFunction->uploadTexture(); - OsEng.renderEngine().abuffer()->addTransferFunction(_transferFunctionName, _transferFunction); + OsEng.renderEngine()->abuffer()->addTransferFunction(_transferFunctionName, _transferFunction); auto textureCallback = [this](const ghoul::filesystem::File& file) { _updateTransferfunction = true; @@ -193,9 +195,9 @@ bool RenderableVolumeGL::initialize() { } // add the sampler and get the ID - _id = OsEng.renderEngine().abuffer()->addSamplerfile(_samplerFilename); + _id = OsEng.renderEngine()->abuffer()->addSamplerfile(_samplerFilename); - OsEng.configurationManager().getValue("RaycastProgram", _boxProgram); + OsEng.configurationManager()->getValue("RaycastProgram", _boxProgram); // ============================ // GEOMETRY (box) diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 0aeef5e88a..1c66ad509e 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -87,7 +88,7 @@ int takeScreenshot(lua_State* L) { int nArguments = lua_gettop(L); if (nArguments != 0) return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - OsEng.renderEngine().takeScreenshot(); + OsEng.renderEngine()->takeScreenshot(); return 0; } @@ -103,7 +104,7 @@ int visualizeABuffer(lua_State* L) { const int type = lua_type(L, -1); bool b = lua_toboolean(L, -1) != 0; - OsEng.renderEngine().toggleVisualizeABuffer(b); + OsEng.renderEngine()->toggleVisualizeABuffer(b); return 0; } @@ -119,7 +120,7 @@ int showRenderInformation(lua_State* L) { const int type = lua_type(L, -1); bool b = lua_toboolean(L, -1) != 0; - OsEng.renderEngine().toggleInfoText(b); + OsEng.renderEngine()->toggleInfoText(b); return 0; } @@ -134,7 +135,7 @@ int setPerformanceMeasurement(lua_State* L) { return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); bool b = lua_toboolean(L, -1) != 0; - OsEng.renderEngine().setPerformanceMeasurements(b); + OsEng.renderEngine()->setPerformanceMeasurements(b); return 0; } @@ -183,7 +184,7 @@ bool RenderEngine::initialize() _mainCamera = new Camera(); _mainCamera->setScaling(glm::vec2(1.0, -8.0)); _mainCamera->setPosition(psc(0.f, 0.f, 1.499823f, 11.f)); - OsEng.interactionHandler().setCamera(_mainCamera); + OsEng.interactionHandler()->setCamera(_mainCamera); #ifdef GHOUL_USE_DEVIL ghoul::io::TextureReader::ref().addReader(new ghoul::io::impl::TextureReaderDevIL); @@ -337,7 +338,7 @@ void RenderEngine::postSynchronizationPreDraw() //Allow focus node to update camera (enables camera-following) //FIX LATER: THIS CAUSES MASTER NODE TO BE ONE FRAME AHEAD OF SLAVES - if (const SceneGraphNode* node = OsEng.ref().interactionHandler().focusNode()){ + if (const SceneGraphNode* node = OsEng.ref().interactionHandler()->focusNode()){ node->updateCamera(_mainCamera); } @@ -426,7 +427,7 @@ void RenderEngine::render() const glm::vec2 scaling = _mainCamera->scaling(); const glm::vec3 viewdirection = _mainCamera->viewDirection(); const psc position = _mainCamera->position(); - const psc origin = OsEng.interactionHandler().focusNode()->worldPosition(); + const psc origin = OsEng.interactionHandler()->focusNode()->worldPosition(); const PowerScaledScalar pssl = (position - origin).length(); // GUI PRINT diff --git a/src/scenegraph/scenegraph.cpp b/src/scenegraph/scenegraph.cpp index fbe254b521..91401f45d1 100644 --- a/src/scenegraph/scenegraph.cpp +++ b/src/scenegraph/scenegraph.cpp @@ -23,25 +23,27 @@ ****************************************************************************************/ #include -#include + +#include +#include #include +#include #include +#include +#include +#include #include #include -#include #include -#include -#include - -#include "ghoul/logging/logmanager.h" -#include "ghoul/opengl/programobject.h" -#include "ghoul/io/texture/texturereader.h" -#include "ghoul/opengl/texture.h" #include +#include "ghoul/io/texture/texturereader.h" #include +#include "ghoul/logging/logmanager.h" #include #include +#include "ghoul/opengl/programobject.h" +#include "ghoul/opengl/texture.h" #include #include @@ -125,7 +127,7 @@ int loadScene(lua_State* L) { std::string sceneFile = luaL_checkstring(L, -1); - OsEng.renderEngine().sceneGraph()->scheduleLoadSceneFile(sceneFile); + OsEng.renderEngine()->sceneGraph()->scheduleLoadSceneFile(sceneFile); return 0; } @@ -170,7 +172,7 @@ bool SceneGraph::initialize() if( ! tmpProgram) return false; tmpProgram->setProgramObjectCallback(cb); _programs.push_back(tmpProgram); - OsEng.ref().configurationManager().setValue("pscShader", tmpProgram); + OsEng.ref().configurationManager()->setValue("pscShader", tmpProgram); // RaycastProgram tmpProgram = ProgramObject::Build("RaycastProgram", @@ -179,7 +181,7 @@ bool SceneGraph::initialize() if (!tmpProgram) return false; tmpProgram->setProgramObjectCallback(cb); _programs.push_back(tmpProgram); - OsEng.ref().configurationManager().setValue("RaycastProgram", tmpProgram); + OsEng.ref().configurationManager()->setValue("RaycastProgram", tmpProgram); // Grid program tmpProgram = ProgramObject::Build("Grid", @@ -188,7 +190,7 @@ bool SceneGraph::initialize() if (!tmpProgram) return false; tmpProgram->setProgramObjectCallback(cb); _programs.push_back(tmpProgram); - OsEng.ref().configurationManager().setValue("GridProgram", tmpProgram); + OsEng.ref().configurationManager()->setValue("GridProgram", tmpProgram); // Done building shaders double elapsed = std::chrono::duration_cast(clock_::now()-beginning).count(); @@ -213,13 +215,13 @@ bool SceneGraph::deinitialize() void SceneGraph::update(const UpdateData& data) { if (!_sceneGraphToLoad.empty()) { - OsEng.renderEngine().sceneGraph()->clearSceneGraph(); + OsEng.renderEngine()->sceneGraph()->clearSceneGraph(); bool success = loadSceneInternal(_sceneGraphToLoad); _sceneGraphToLoad = ""; if (!success) return; #ifndef __APPLE__ - OsEng.renderEngine().abuffer()->invalidateABuffer(); + OsEng.renderEngine()->abuffer()->invalidateABuffer(); #endif } for (SceneGraphNode* node : _nodes) @@ -360,7 +362,7 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath) _root->calculateBoundingSphere(); // set the camera position - Camera* c = OsEng.ref().renderEngine().camera(); + Camera* c = OsEng.ref().renderEngine()->camera(); auto focusIterator = _allNodes.find(_focus); glm::vec2 cameraScaling(1); @@ -400,7 +402,7 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath) // c->setScaling(scaling); // Set the focus node for the interactionhandler - OsEng.interactionHandler().setFocusNode(focusNode); + OsEng.interactionHandler()->setFocusNode(focusNode); } glm::vec4 position; @@ -418,7 +420,7 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath) } // the camera position - const SceneGraphNode* fn = OsEng.interactionHandler().focusNode(); + const SceneGraphNode* fn = OsEng.interactionHandler()->focusNode(); //psc relative = fn->worldPosition() - c->position(); psc relative = fn->worldPosition() - cameraPosition; @@ -439,7 +441,7 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath) for (SceneGraphNode* node : _nodes) { std::vector properties = node->propertiesRecursive(); for (properties::Property* p : properties) { - OsEng.gui().registerProperty(p); + OsEng.gui()->registerProperty(p); } }