diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index ee36f2f0f8..f8b614b8ad 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -50,6 +50,7 @@ class RenderEngine; class SyncBuffer; class ModuleEngine; class WindowWrapper; +class SettingsEngine; namespace interaction { class InteractionHandler; } namespace gui { class GUI; } @@ -130,13 +131,14 @@ private: std::unique_ptr _commandlineParser; std::unique_ptr _console; std::unique_ptr _moduleEngine; + std::unique_ptr _settingsEngine; #ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED std::unique_ptr _gui; #endif std::unique_ptr _parallelConnection; std::unique_ptr _windowWrapper; std::unique_ptr _fontManager; - + // Others std::unique_ptr _globalPropertyNamespace; std::unique_ptr _syncBuffer; diff --git a/include/openspace/engine/settingsengine.h b/include/openspace/engine/settingsengine.h new file mode 100644 index 0000000000..583abba854 --- /dev/null +++ b/include/openspace/engine/settingsengine.h @@ -0,0 +1,44 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __SETTINGSENGINE_H__ +#define __SETTINGSENGINE_H__ + +#include +#include + +namespace openspace { + +class SettingsEngine : public properties::PropertyOwner { +public: + SettingsEngine(); + +private: + properties::FloatProperty _eyeSeparation; +}; + +} // namespace openspace + + +#endif //#ifndef __SETTINGSENGINE_H__ diff --git a/include/openspace/engine/wrapper/sgctwindowwrapper.h b/include/openspace/engine/wrapper/sgctwindowwrapper.h index 3b19931658..02058dd45c 100644 --- a/include/openspace/engine/wrapper/sgctwindowwrapper.h +++ b/include/openspace/engine/wrapper/sgctwindowwrapper.h @@ -53,6 +53,7 @@ public: glm::mat4 viewProjectionMatrix() const override; glm::mat4 modelMatrix() const override; void setNearFarClippingPlane(float near, float far) override; + void setEyeSeparationDistance(float distance) override; glm::ivec4 viewportPixelCoordinates() const override; diff --git a/include/openspace/engine/wrapper/windowwrapper.h b/include/openspace/engine/wrapper/windowwrapper.h index 5cc4e430e9..473e9ab8e8 100644 --- a/include/openspace/engine/wrapper/windowwrapper.h +++ b/include/openspace/engine/wrapper/windowwrapper.h @@ -147,6 +147,12 @@ public: */ virtual void setNearFarClippingPlane(float near, float far); + /** + * Sets the stereo eye separation distance for the render engine. + * \param distance The distance between eyes for stereo rendering. + */ + virtual void setEyeSeparationDistance(float distance); + /** * Returns the location and size of the current viewport (x, * width, y, and height). If there is only a diff --git a/modules/onscreengui/include/gui.h b/modules/onscreengui/include/gui.h index 7bd37b0f85..fb15983609 100644 --- a/modules/onscreengui/include/gui.h +++ b/modules/onscreengui/include/gui.h @@ -74,6 +74,7 @@ public: GuiPropertyComponent _property; // GuiPropertyComponent _iSWAproperty; GuiPropertyComponent _screenSpaceProperty; + GuiPropertyComponent _globalProperty; GuiTimeComponent _time; GuiIswaComponent _iswa; diff --git a/modules/onscreengui/src/gui.cpp b/modules/onscreengui/src/gui.cpp index 4353468086..7f4d62008c 100644 --- a/modules/onscreengui/src/gui.cpp +++ b/modules/onscreengui/src/gui.cpp @@ -206,6 +206,7 @@ void GUI::initialize() { _property.initialize(); _screenSpaceProperty.initialize(); + _globalProperty.initialize(); _performance.initialize(); _help.initialize(); _iswa.initialize(); @@ -254,6 +255,7 @@ void GUI::initializeGL() { _property.initializeGL(); _screenSpaceProperty.initializeGL(); + _globalProperty.initializeGL(); _performance.initializeGL(); _help.initializeGL(); _iswa.initializeGL(); @@ -267,6 +269,7 @@ void GUI::deinitializeGL() { _property.deinitializeGL(); _screenSpaceProperty.deinitializeGL(); + _globalProperty.deinitializeGL(); _performance.deinitializeGL(); _help.deinitializeGL(); _iswa.deinitializeGL(); @@ -302,6 +305,8 @@ void GUI::endFrame() { _property.render(); if (_screenSpaceProperty.isEnabled()) _screenSpaceProperty.render(); + if (_globalProperty.isEnabled()) + _globalProperty.render(); if (_performance.isEnabled()) _performance.render(); if (_help.isEnabled()) @@ -404,6 +409,7 @@ void GUI::renderMainWindow() { ImGui::Checkbox("Scene Graph Properties", &_property._isEnabled); ImGui::Checkbox("ScreenSpace Properties", &_screenSpaceProperty._isEnabled); + ImGui::Checkbox("Global Properties", &_globalProperty._isEnabled); #ifdef OPENSPACE_MODULE_ISWA_ENABLED ImGui::Checkbox("iSWA", &_iswa._isEnabled); #endif diff --git a/shaders/PowerScaling/powerScaling_fs.hglsl b/shaders/PowerScaling/powerScaling_fs.hglsl index ba2442ebcf..855c98707a 100644 --- a/shaders/PowerScaling/powerScaling_fs.hglsl +++ b/shaders/PowerScaling/powerScaling_fs.hglsl @@ -53,11 +53,7 @@ float pscDepth(vec4 position) { // For now: simply convert power scaled coordinates to a linear scale. // TODO: get rid of power scaled coordinates and use scale graph instead. // return (position.w + log(abs(position.z) + 1/pow(k, position.w))/log(k)) / 27.0; - if (position.z < 0) { - return safeLength(pscToLinear(position)); - } else { - return -safeLength(pscToLinear(position)); - } + return safeLength(pscToLinear(position)); } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1d7d1a7670..1dd0430a65 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,6 +30,7 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/engine/moduleengine.cpp ${OPENSPACE_BASE_DIR}/src/engine/moduleengine_lua.inl ${OPENSPACE_BASE_DIR}/src/engine/openspaceengine.cpp + ${OPENSPACE_BASE_DIR}/src/engine/settingsengine.cpp ${OPENSPACE_BASE_DIR}/src/engine/wrapper/sgctwindowwrapper.cpp ${OPENSPACE_BASE_DIR}/src/engine/wrapper/windowwrapper.cpp ${OPENSPACE_BASE_DIR}/src/interaction/controller.cpp @@ -104,6 +105,7 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/engine/logfactory.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/moduleengine.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/openspaceengine.h + ${OPENSPACE_BASE_DIR}/include/openspace/engine/settingsengine.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/wrapper/sgctwindowwrapper.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/wrapper/windowwrapper.h ${OPENSPACE_BASE_DIR}/include/openspace/interaction/controller.h diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 305450fe5e..a6853abaa1 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -109,6 +110,10 @@ namespace { namespace openspace { +namespace properties { + class Property; +} + OpenSpaceEngine* OpenSpaceEngine::_engine = nullptr; OpenSpaceEngine::OpenSpaceEngine(std::string programName, @@ -123,6 +128,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName, )) , _console(new LuaConsole) , _moduleEngine(new ModuleEngine) + , _settingsEngine(new SettingsEngine) #ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED , _gui(new gui::GUI) #endif @@ -135,6 +141,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName, { _interactionHandler->setPropertyOwner(_globalPropertyNamespace.get()); _globalPropertyNamespace->addPropertySubOwner(_interactionHandler.get()); + _globalPropertyNamespace->addPropertySubOwner(_settingsEngine.get()); FactoryManager::initialize(); FactoryManager::ref().addFactory( std::make_unique>() @@ -165,6 +172,7 @@ OpenSpaceEngine::~OpenSpaceEngine() { _commandlineParser = nullptr; _console = nullptr; _moduleEngine = nullptr; + _settingsEngine = nullptr; #ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED _gui = nullptr; #endif @@ -429,6 +437,8 @@ bool OpenSpaceEngine::initialize() { #ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED LINFO("Initializing GUI"); _gui->initialize(); + for (properties::Property* p : _settingsEngine->propertiesRecursive()) + _gui->_globalProperty.registerProperty(p); #endif #ifdef OPENSPACE_MODULE_ISWA_ENABLED diff --git a/src/engine/settingsengine.cpp b/src/engine/settingsengine.cpp new file mode 100644 index 0000000000..0dd553da15 --- /dev/null +++ b/src/engine/settingsengine.cpp @@ -0,0 +1,41 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * 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 + +namespace openspace { + +SettingsEngine::SettingsEngine() : + _eyeSeparation("eyeSeparation", "Eye Separation" , 0.f, 0.f, 10.f) +{ + addProperty(_eyeSeparation); + setName("Global"); + _eyeSeparation.onChange( + [this](){ OsEng.windowWrapper().setEyeSeparationDistance(_eyeSeparation); }); +} + +} diff --git a/src/engine/wrapper/sgctwindowwrapper.cpp b/src/engine/wrapper/sgctwindowwrapper.cpp index f566276a39..c79743a9e3 100644 --- a/src/engine/wrapper/sgctwindowwrapper.cpp +++ b/src/engine/wrapper/sgctwindowwrapper.cpp @@ -123,7 +123,11 @@ glm::mat4 SGCTWindowWrapper::modelMatrix() const { void SGCTWindowWrapper::setNearFarClippingPlane(float nearPlane, float farPlane) { sgct::Engine::instance()->setNearAndFarClippingPlanes(nearPlane, farPlane); } - + +void SGCTWindowWrapper::setEyeSeparationDistance(float distance) { + sgct::Engine::instance()->setEyeSeparation(distance); +} + glm::ivec4 SGCTWindowWrapper::viewportPixelCoordinates() const { int x1, xSize, y1, ySize; sgct::Engine::instance()->getCurrentWindowPtr()->getCurrentViewportPixelCoords(x1, diff --git a/src/engine/wrapper/windowwrapper.cpp b/src/engine/wrapper/windowwrapper.cpp index 17344d9f8a..cda6214a7f 100644 --- a/src/engine/wrapper/windowwrapper.cpp +++ b/src/engine/wrapper/windowwrapper.cpp @@ -81,6 +81,8 @@ glm::mat4 WindowWrapper::modelMatrix() const { } void WindowWrapper::setNearFarClippingPlane(float near, float far) {} + +void WindowWrapper::setEyeSeparationDistance(float distance) {} glm::ivec4 WindowWrapper::viewportPixelCoordinates() const { return glm::ivec4( diff --git a/src/performance/performancemeasurement.cpp b/src/performance/performancemeasurement.cpp index a62a6d5d4e..722d7b965d 100644 --- a/src/performance/performancemeasurement.cpp +++ b/src/performance/performancemeasurement.cpp @@ -46,6 +46,7 @@ PerformanceMeasurement::PerformanceMeasurement(std::string identifier, } PerformanceMeasurement::~PerformanceMeasurement() { + glFinish(); auto endTime = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_cast( endTime - _startTime).count();