From a837b59add29c9e354494756e9fc40ef9b3e3ac2 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 10 Feb 2015 20:19:29 +0100 Subject: [PATCH 01/12] First addition of RenderableSphere --- .../openspace/rendering/renderablesphere.h | 73 +++++++ src/rendering/renderablesphere.cpp | 196 ++++++++++++++++++ src/util/factorymanager.cpp | 3 + 3 files changed, 272 insertions(+) create mode 100644 include/openspace/rendering/renderablesphere.h create mode 100644 src/rendering/renderablesphere.cpp diff --git a/include/openspace/rendering/renderablesphere.h b/include/openspace/rendering/renderablesphere.h new file mode 100644 index 0000000000..f6e5ddda39 --- /dev/null +++ b/include/openspace/rendering/renderablesphere.h @@ -0,0 +1,73 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014 * + * * + * 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 __RENDERABLESPHERE_H__ +#define __RENDERABLESPHERE_H__ + +#include +#include + +#include +#include +#include +#include +#include + +namespace openspace { + +class PowerScaledSphere; + +class RenderableSphere : public Renderable { +public: + RenderableSphere(const ghoul::Dictionary& dictionary); + ~RenderableSphere(); + + bool initialize() override; + bool deinitialize() override; + + bool isReady() const override; + + void render(const RenderData& data) override; + void update(const UpdateData& data) override; + +private: + void loadTexture(); + + properties::StringProperty _texturePath; + properties::OptionProperty _orientation; + + properties::Vec2Property _size; + properties::IntProperty _segments; + + ghoul::opengl::ProgramObject* _shader; + ghoul::opengl::Texture* _texture; + + PowerScaledSphere* _sphere; + + bool _programIsDirty; + bool _sphereIsDirty; +}; + +} // namespace openspace +#endif // __RENDERABLESPHERE_H__ diff --git a/src/rendering/renderablesphere.cpp b/src/rendering/renderablesphere.cpp new file mode 100644 index 0000000000..476105f44a --- /dev/null +++ b/src/rendering/renderablesphere.cpp @@ -0,0 +1,196 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014 * + * * + * 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 +#include +#include +#include + +#include + + +namespace { + const std::string _loggerCat = "RenderableSphere"; + + const std::string keySize = "Size"; + const std::string keySegments = "Segments"; + const std::string keyTexture = "Texture"; + const std::string keyOrientation = "Orientation"; + + enum Orientation { + Outside = 0, + Inside + }; +} + +namespace openspace { + +RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary) + : Renderable(dictionary) + , _texturePath("texture", "Texture") + , _orientation("orientation", "Orientation") + , _size("size", "Size", glm::vec2(1.f, 1.f), glm::vec2(0.f), glm::vec2(100.f)) + , _segments("segments", "Segments", 8, 4, 100) + , _shader(nullptr) + , _texture(nullptr) + , _sphere(nullptr) + , _programIsDirty(false) + , _sphereIsDirty(false) +{ + std::string path; + bool success = dictionary.getValue(constants::scenegraph::keyPathModule, path); + ghoul_assert(success, + "RenderablePlanet need the '" << constants::scenegraph::keyPathModule << "' be specified"); + + if (dictionary.hasKeyAndValue(keySize)) { + glm::vec2 size; + dictionary.getValue(keySize, size); + _size = size; + } + + if (dictionary.hasKeyAndValue(keySegments)) { + int segments; + dictionary.getValue(keySegments, segments); + _segments = segments; + } + + if (dictionary.hasKeyAndValue(keyTexture)) { + std::string texture; + dictionary.getValue(keyTexture, texture); + _texturePath = path + '/' + texture; + } + + _orientation.addOption(Outside, "Outside"); + _orientation.addOption(Inside, "Inside"); + _orientation.addOption(Outside | Inside, "Outside + Inside"); + + if (dictionary.hasKeyAndValue(keyOrientation)) { + std::string orientation; + dictionary.getValue(keyOrientation, orientation); + if (orientation == "Outside") + _orientation = Outside; + else if (orientation == "Inside") + _orientation = Inside; + else + _orientation = Outside | Inside; + } + + addProperty(_orientation); + addProperty(_size); + _size.onChange([this](){ _sphereIsDirty = true; }); + addProperty(_segments); + _segments.onChange([this](){ _sphereIsDirty = true; }); + + addProperty(_texturePath); + _texturePath.onChange(std::bind(&RenderableSphere::loadTexture, this)); +} + +RenderableSphere::~RenderableSphere() { +} + +bool RenderableSphere::isReady() const { + return (_sphere != nullptr) && (_shader != nullptr) && (_texture != nullptr); +} + +bool RenderableSphere::initialize() { + _sphere = new PowerScaledSphere(_size.value(), _segments); + _sphere->initialize(); + + // pscstandard + _shader = ghoul::opengl::ProgramObject::Build("pscstandard", + "${SHADERS}/plane_vs.glsl", + "${SHADERS}/plane_fs.glsl"); + if (!_shader) + return false; + _shader->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ _programIsDirty = true; }); + + loadTexture(); + + return isReady(); +} + +bool RenderableSphere::deinitialize() { + delete _sphere; + delete _texture; + return true; +} + +void RenderableSphere::render(const RenderData& data) { + + glm::mat4 transform = glm::mat4(1.0); + + // Activate shader + _shader->activate(); + + _shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); + _shader->setUniform("ModelTransform", transform); + setPscUniforms(_shader, &data.camera, data.position); + + ghoul::opengl::TextureUnit unit; + unit.activate(); + _texture->bind(); + _shader->setUniform("texture1", unit); + + _sphere->render(); + + _shader->deactivate(); +} + +void RenderableSphere::update(const UpdateData& data) { + if (_programIsDirty) { + _shader->rebuildFromFile(); + _programIsDirty = false; + } + + if (_sphereIsDirty) { + delete _sphere; + _sphere = new PowerScaledSphere(_size.value(), _segments); + _sphere->initialize(); + _sphereIsDirty = false; + } +} + +void RenderableSphere::loadTexture() { + LDEBUG("loadTexture"); + if (_texturePath.value() != "") { + LDEBUG("loadTexture2"); + ghoul::opengl::Texture* texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath)); + if (texture) { + LDEBUG("Loaded texture from '" << absPath(_texturePath) << "'"); + texture->uploadTexture(); + + // Textures of planets looks much smoother with AnisotropicMipMap rather than linear + texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + + if (_texture) + delete _texture; + _texture = texture; + } + } +} + +} // namespace openspace diff --git a/src/util/factorymanager.cpp b/src/util/factorymanager.cpp index b219a47cb1..10122c69c6 100644 --- a/src/util/factorymanager.cpp +++ b/src/util/factorymanager.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -73,6 +74,8 @@ void FactoryManager::initialize() "RenderableTrail"); _manager->factory()->registerClass( "RenderableFov"); + _manager->factory()->registerClass( + "RenderableSphere"); _manager->factory()->registerClass( "RenderableSphericalGrid"); _manager->factory()->registerClass( From aed5d295f7cd3278abb7164a838aefd24e01a8e9 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 10 Feb 2015 20:20:04 +0100 Subject: [PATCH 02/12] Added openspace-data update --- openspace-data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openspace-data b/openspace-data index 2e076f2479..a3ca7c8c8f 160000 --- a/openspace-data +++ b/openspace-data @@ -1 +1 @@ -Subproject commit 2e076f247966d2b0bb4923440a0ad7f9e5cd8d4b +Subproject commit a3ca7c8c8f1aeba58128d1732aeb63ebf0cc121e From bb5f6e1bca67c56d7df94b3f877eecb26db39d79 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 16 Feb 2015 22:13:03 +0100 Subject: [PATCH 03/12] Renamed member variable of SimpleSphereGeometry from _planet to _sphere --- .../rendering/planets/simplespheregeometry.h | 2 +- src/rendering/planets/simplespheregeometry.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/openspace/rendering/planets/simplespheregeometry.h b/include/openspace/rendering/planets/simplespheregeometry.h index 2bbc012261..f2e7df8691 100644 --- a/include/openspace/rendering/planets/simplespheregeometry.h +++ b/include/openspace/rendering/planets/simplespheregeometry.h @@ -52,7 +52,7 @@ private: properties::Vec2Property _radius; properties::IntProperty _segments; - PowerScaledSphere* _planet; + PowerScaledSphere* _sphere; }; } // namespace planetgeometry diff --git a/src/rendering/planets/simplespheregeometry.cpp b/src/rendering/planets/simplespheregeometry.cpp index d57ce7de9d..7a5dd02f17 100644 --- a/src/rendering/planets/simplespheregeometry.cpp +++ b/src/rendering/planets/simplespheregeometry.cpp @@ -46,7 +46,7 @@ SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary) , _radius("radius", "Radius", glm::vec2(1.f, 0.f), glm::vec2(-10.f, -20.f), glm::vec2(10.f, 20.f)) , _segments("segments", "Segments", 20, 1, 50) - , _planet(nullptr) + , _sphere(nullptr) { using constants::scenegraphnode::keyName; using constants::simplespheregeometry::keyRadius; @@ -94,14 +94,14 @@ bool SimpleSphereGeometry::initialize(RenderablePlanet* parent) void SimpleSphereGeometry::deinitialize() { - if (_planet) - delete _planet; - _planet = nullptr; + if (_sphere) + delete _sphere; + _sphere = nullptr; } void SimpleSphereGeometry::render() { - _planet->render(); + _sphere->render(); } void SimpleSphereGeometry::createSphere() @@ -111,11 +111,11 @@ void SimpleSphereGeometry::createSphere() PowerScaledScalar planetSize(_radius); _parent->setBoundingSphere(planetSize); - if(_planet) - delete _planet; + if(_sphere) + delete _sphere; - _planet = new PowerScaledSphere(planetSize, _segments); - _planet->initialize(); + _sphere = new PowerScaledSphere(planetSize, _segments); + _sphere->initialize(); } } // namespace planetgeometry From 98aeeda24d6a2df803e4f715622d1da8ba5ff1e9 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 16 Feb 2015 23:16:06 +0100 Subject: [PATCH 04/12] Added support for variable transparency in RenderableSphere Created own shaders for RenderableSphere --- .../openspace/rendering/renderablesphere.h | 2 + openspace-data | 2 +- shaders/modules/sphere/sphere_fs.glsl | 74 +++++++++++++++++++ shaders/modules/sphere/sphere_vs.glsl | 57 ++++++++++++++ src/rendering/renderablesphere.cpp | 20 +++-- 5 files changed, 149 insertions(+), 6 deletions(-) create mode 100644 shaders/modules/sphere/sphere_fs.glsl create mode 100644 shaders/modules/sphere/sphere_vs.glsl diff --git a/include/openspace/rendering/renderablesphere.h b/include/openspace/rendering/renderablesphere.h index f6e5ddda39..de5ecdbe3f 100644 --- a/include/openspace/rendering/renderablesphere.h +++ b/include/openspace/rendering/renderablesphere.h @@ -60,6 +60,8 @@ private: properties::Vec2Property _size; properties::IntProperty _segments; + properties::FloatProperty _transparency; + ghoul::opengl::ProgramObject* _shader; ghoul::opengl::Texture* _texture; diff --git a/openspace-data b/openspace-data index 28895f9911..b090a44cd3 160000 --- a/openspace-data +++ b/openspace-data @@ -1 +1 @@ -Subproject commit 28895f991124dd03dfd21127b49a22153e99f870 +Subproject commit b090a44cd304ba1e4393749f6f1688086a9d810c diff --git a/shaders/modules/sphere/sphere_fs.glsl b/shaders/modules/sphere/sphere_fs.glsl new file mode 100644 index 0000000000..046dd1bcdd --- /dev/null +++ b/shaders/modules/sphere/sphere_fs.glsl @@ -0,0 +1,74 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014 * + * * + * 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. * + ****************************************************************************************/ + +#version __CONTEXT__ + +uniform float time; +uniform sampler2D texture1; +uniform float alpha; + +in vec2 vs_st; +in vec4 vs_position; + +#include "ABuffer/abufferStruct.hglsl" +#include "ABuffer/abufferAddToBuffer.hglsl" +#include "PowerScaling/powerScaling_fs.hglsl" + +void main() +{ + vec4 position = vs_position; + // This has to be fixed with the ScaleGraph in place (precision deficiency in depth buffer) ---abock + // float depth = pscDepth(position); + float depth = 1000.0; + vec4 diffuse; + // if(gl_FrontFacing) + diffuse = texture(texture1, vs_st); + // else + // diffuse = texture(texture1, vec2(1-vs_st.s,vs_st.t)); + + diffuse.a *= alpha; + + //vec4 diffuse = vec4(1,vs_st,1); + //vec4 diffuse = vec4(1,0,0,1); + // if(position.w > 9.0) { + // diffuse = vec4(1,0,0,1); + // } + + + // #if 0 + // diffuse = vec4(vs_position.xyz / 10, 1.0); + // #else + // // if (abs(vs_st.r - 0.75) <= 0.01 && abs(vs_st.g - 0.5) <= 0.01) + // if (abs(vs_st.g - 0.5) <= 0.01) + // diffuse = vec4(vec2(vs_st), 0.0, 1.0); + // else + // diffuse = vec4(0.0); + // #endif + + // diffuse = vec4(1.0, 0.0, 0.0, 1.0); + + ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth); + addToBuffer(frag); + +} \ No newline at end of file diff --git a/shaders/modules/sphere/sphere_vs.glsl b/shaders/modules/sphere/sphere_vs.glsl new file mode 100644 index 0000000000..8933103c00 --- /dev/null +++ b/shaders/modules/sphere/sphere_vs.glsl @@ -0,0 +1,57 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014 * + * * + * 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. * + ****************************************************************************************/ + +#version __CONTEXT__ + +uniform mat4 ViewProjection; +uniform mat4 ModelTransform; + +layout(location = 0) in vec4 in_position; +layout(location = 1) in vec2 in_st; + +out vec2 vs_st; +out vec4 vs_position; +out float s; + +#include "PowerScaling/powerScaling_vs.hglsl" + +void main() +{ + vec4 tmp = in_position; + + mat4 mt = ModelTransform; + + mt = mat4(0, -1, 0, 0, + 1, 0, 0, 0, + 0, 0, -1, 0, + 0, 0, 0, 1) * mt; + + vec4 position = pscTransform(tmp, mt); + + vs_position = in_position; + vs_st = in_st; + + position = ViewProjection * position; + gl_Position = z_normalization(position); +} \ No newline at end of file diff --git a/src/rendering/renderablesphere.cpp b/src/rendering/renderablesphere.cpp index 476105f44a..7f52897b37 100644 --- a/src/rendering/renderablesphere.cpp +++ b/src/rendering/renderablesphere.cpp @@ -42,8 +42,8 @@ namespace { const std::string keyOrientation = "Orientation"; enum Orientation { - Outside = 0, - Inside + Outside = 1, + Inside = 2 }; } @@ -55,6 +55,7 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary) , _orientation("orientation", "Orientation") , _size("size", "Size", glm::vec2(1.f, 1.f), glm::vec2(0.f), glm::vec2(100.f)) , _segments("segments", "Segments", 8, 4, 100) + , _transparency("transparency", "Transparency", 1.f, 0.f, 1.f) , _shader(nullptr) , _texture(nullptr) , _sphere(nullptr) @@ -105,6 +106,8 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary) addProperty(_segments); _segments.onChange([this](){ _sphereIsDirty = true; }); + addProperty(_transparency); + addProperty(_texturePath); _texturePath.onChange(std::bind(&RenderableSphere::loadTexture, this)); } @@ -121,9 +124,9 @@ bool RenderableSphere::initialize() { _sphere->initialize(); // pscstandard - _shader = ghoul::opengl::ProgramObject::Build("pscstandard", - "${SHADERS}/plane_vs.glsl", - "${SHADERS}/plane_fs.glsl"); + _shader = ghoul::opengl::ProgramObject::Build("Sphere", + "${SHADERS}/modules/sphere/sphere_vs.glsl", + "${SHADERS}/modules/sphere/sphere_fs.glsl"); if (!_shader) return false; _shader->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ _programIsDirty = true; }); @@ -143,13 +146,19 @@ void RenderableSphere::render(const RenderData& data) { glm::mat4 transform = glm::mat4(1.0); + transform = glm::rotate(transform, 90.f, glm::vec3(1, 0, 0)); + + // Activate shader _shader->activate(); + _shader->setIgnoreUniformLocationError(true); _shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); _shader->setUniform("ModelTransform", transform); setPscUniforms(_shader, &data.camera, data.position); + _shader->setUniform("alpha", _transparency); + ghoul::opengl::TextureUnit unit; unit.activate(); _texture->bind(); @@ -157,6 +166,7 @@ void RenderableSphere::render(const RenderData& data) { _sphere->render(); + _shader->setIgnoreUniformLocationError(false); _shader->deactivate(); } From d96dc3884c0571e983b4c5a88fbeeaa68ae33c87 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 17 Feb 2015 09:31:58 +0100 Subject: [PATCH 05/12] Added properties to change the appearance of stars --- .../rendering/stars/renderablestars.h | 8 +++--- shaders/modules/stars/star_ge.glsl | 13 ++++++--- src/rendering/stars/renderablestars.cpp | 27 +++++++++++++------ 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/include/openspace/rendering/stars/renderablestars.h b/include/openspace/rendering/stars/renderablestars.h index f7da38ca55..d16a432b3b 100644 --- a/include/openspace/rendering/stars/renderablestars.h +++ b/include/openspace/rendering/stars/renderablestars.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -69,12 +70,13 @@ private: ghoul::opengl::Texture* _colorTexture; bool _colorTextureIsDirty; - properties::OptionProperty _colorOption; bool _dataIsDirty; - properties::FloatProperty _spriteBaseSize; - properties::FloatProperty _spriteResponseSize; + properties::Vec2Property _magnitudeClamp; + properties::FloatProperty _exponentialOffset; + properties::FloatProperty _exponentialDampening; + properties::FloatProperty _scaleFactor; ghoul::opengl::ProgramObject* _program; bool _programIsDirty; diff --git a/shaders/modules/stars/star_ge.glsl b/shaders/modules/stars/star_ge.glsl index cc8f26ece2..f9dbb6ccc8 100644 --- a/shaders/modules/stars/star_ge.glsl +++ b/shaders/modules/stars/star_ge.glsl @@ -51,8 +51,11 @@ layout(location = 4) out vec2 texCoord; uniform mat4 projection; -uniform float spriteBaseSize; -uniform float spriteResponseSize; +uniform vec2 magnitudeClamp; +uniform float exponentialOffset; +uniform float exponentialDampening; +uniform float scaleFactor; + // As soon as the scalegraph is in place, replace this by a dynamic calculation // of apparent magnitude in relation to the camera position ---abock @@ -67,8 +70,10 @@ void main() { float M = vs_brightness[0].z; - M = clamp(M, 1.0, 4.0); - float modifiedSpriteSize = exp((-5 - M) * 0.871); + // M = clamp(M, 1.0, 4.0); + M = clamp(M, magnitudeClamp[0], magnitudeClamp[1]); + // float modifiedSpriteSize = exp((-5 - M) * 0.871); + float modifiedSpriteSize = exp((-exponentialOffset - M) * exponentialDampening) * scaleFactor; for(int i = 0; i < 4; i++){ vec4 p1 = gl_in[0].gl_Position; diff --git a/src/rendering/stars/renderablestars.cpp b/src/rendering/stars/renderablestars.cpp index 2a4ff6dedb..49c5e6e2cd 100644 --- a/src/rendering/stars/renderablestars.cpp +++ b/src/rendering/stars/renderablestars.cpp @@ -84,8 +84,16 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) , _colorTextureIsDirty(true) , _colorOption("colorOption", "Color Option") , _dataIsDirty(true) - , _spriteBaseSize("spriteBaseSize", "Sprite Base Size", 0.1f, 0.f, 10.f) - , _spriteResponseSize("spriteResponseSize", "Sprite Response Size", 1.f, 0.f, 10.f) + , _magnitudeClamp( + "magnitudeClamp", + "Magnitude Clamping", + glm::vec2(1.f, 4.f), + glm::vec2(-15.f), + glm::vec2(15.f) + ) + , _exponentialOffset("exponentialOffset", "Exponential Offset", 5.f, 0.f, 10.f) + , _exponentialDampening("exponentialDampening", "Exponential Dampening", 0.871f, 0.f, 1.f) + , _scaleFactor("scaleFactor", "Scale Factor", 1.f, 0.f, 10.f) , _program(nullptr) , _programIsDirty(false) , _speckFile("") @@ -114,14 +122,16 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) addProperty(_colorOption); _colorOption.onChange([&]{ _dataIsDirty = true;}); - addProperty(_spriteBaseSize); - addProperty(_spriteResponseSize); - addProperty(_pointSpreadFunctionTexturePath); _pointSpreadFunctionTexturePath.onChange([&]{ _pointSpreadFunctionTextureIsDirty = true;}); addProperty(_colorTexturePath); _colorTexturePath.onChange([&]{ _colorTextureIsDirty = true; }); + + addProperty(_magnitudeClamp); + addProperty(_exponentialOffset); + addProperty(_exponentialDampening); + addProperty(_scaleFactor); } RenderableStars::~RenderableStars() { @@ -181,13 +191,14 @@ void RenderableStars::render(const RenderData& data) { _program->setUniform("projection", projectionMatrix); _program->setUniform("colorOption", _colorOption); + _program->setUniform("magnitudeClamp", _magnitudeClamp); + _program->setUniform("exponentialOffset", _exponentialOffset); + _program->setUniform("exponentialDampening", _exponentialDampening); + _program->setUniform("scaleFactor", _scaleFactor); setPscUniforms(_program, &data.camera, data.position); _program->setUniform("scaling", scaling); - _program->setUniform("spriteBaseSize", _spriteBaseSize); - _program->setUniform("spriteResponseSize", _spriteResponseSize); - ghoul::opengl::TextureUnit psfUnit; psfUnit.activate(); if (_pointSpreadFunctionTexture) From 26e69b2b2c17d3dc7a109cada3a4eac6335718bd Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 17 Feb 2015 09:32:57 +0100 Subject: [PATCH 06/12] Updated openspace-data version --- openspace-data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openspace-data b/openspace-data index 2e076f2479..b090a44cd3 160000 --- a/openspace-data +++ b/openspace-data @@ -1 +1 @@ -Subproject commit 2e076f247966d2b0bb4923440a0ad7f9e5cd8d4b +Subproject commit b090a44cd304ba1e4393749f6f1688086a9d810c From 862bfd6947635ff47d1c26f54f621656a624c6a6 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 17 Feb 2015 10:36:18 +0100 Subject: [PATCH 07/12] 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); } } From 64db01420cd54dcecd6c0707a3d18d4deb534f05 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 17 Feb 2015 10:40:10 +0100 Subject: [PATCH 08/12] Added missing include for Linux compile --- src/abuffer/abufferfixed.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/abuffer/abufferfixed.cpp b/src/abuffer/abufferfixed.cpp index 2d04a48330..113a4fc4ff 100644 --- a/src/abuffer/abufferfixed.cpp +++ b/src/abuffer/abufferfixed.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include From a2e58f8f7c64d21988007bae40fb838f5abbfcfe Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 17 Feb 2015 10:45:27 +0100 Subject: [PATCH 09/12] Added missing include for Linux compile --- src/abuffer/abufferdynamic.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/abuffer/abufferdynamic.cpp b/src/abuffer/abufferdynamic.cpp index eae0efbd72..51a34bc037 100644 --- a/src/abuffer/abufferdynamic.cpp +++ b/src/abuffer/abufferdynamic.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include From e712a1e78120e9802ef3a2a789be5f272bd30424 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 17 Feb 2015 10:57:10 +0100 Subject: [PATCH 10/12] Added missing include for Linux compile --- src/abuffer/abufferSingleLinked.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/abuffer/abufferSingleLinked.cpp b/src/abuffer/abufferSingleLinked.cpp index 50c7a0f6a6..db09e6cb27 100644 --- a/src/abuffer/abufferSingleLinked.cpp +++ b/src/abuffer/abufferSingleLinked.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include From e30ca93f69842e97117242652cb9ba29bdc4bb31 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 17 Feb 2015 11:13:06 +0100 Subject: [PATCH 11/12] Enabled multicore compilation on default Added newest Ghoul version --- CMakeLists.txt | 8 +++++++- ext/ghoul | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f8dc30076..d827e8d9d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,9 +55,15 @@ if(NOT CMAKE_BUILD_TYPE) FORCE ) endif(NOT CMAKE_BUILD_TYPE) -if (APPLE ) +if (APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++") endif () + +if (MSVC) + # Enable multicore compilation + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") +endif () + ######################################################################################### # External Third-party software ######################################################################################### diff --git a/ext/ghoul b/ext/ghoul index bd99173523..a1e8cb2a8c 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit bd991735238b192a0456618ee2ba2ff616b5b797 +Subproject commit a1e8cb2a8c4dccd4f8eb8e484bd5e6b1eaa24459 From 234b46dbdcf03aafd0f60602495095a22d0aeca5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 17 Feb 2015 11:19:51 +0100 Subject: [PATCH 12/12] Apply newer Ghoul version --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index a1e8cb2a8c..f5f672e439 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit a1e8cb2a8c4dccd4f8eb8e484bd5e6b1eaa24459 +Subproject commit f5f672e4390f7fce76414869f23fc2feb5aa7636