From c92fc923f9f52a09010648564d31af40c93f7b3e Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 14 Dec 2015 17:21:22 -0800 Subject: [PATCH] Remove constants.h file Reenable LuaConsole rendering --- ext/ghoul | 2 +- .../openspace/engine/configurationmanager.h | 1 - include/openspace/rendering/renderengine.h | 3 + include/openspace/util/constants.h | 47 -------------- modules/base/rendering/renderablemodel.cpp | 5 +- modules/base/rendering/renderableplanet.cpp | 7 ++- .../base/rendering/simplespheregeometry.cpp | 4 +- .../rendering/renderablefieldlines.cpp | 5 +- .../rendering/renderablemodelprojection.cpp | 5 +- .../rendering/renderableplanetprojection.cpp | 5 +- .../simplespheregeometryprojection.cpp | 4 +- .../volume/rendering/renderablevolumegl.cpp | 3 +- src/abuffer/abuffervisualizer.cpp | 62 +++++++++---------- src/engine/configurationmanager.cpp | 2 - src/interaction/luaconsole.cpp | 20 ++++-- src/rendering/renderable.cpp | 7 ++- src/rendering/renderengine.cpp | 9 ++- 17 files changed, 83 insertions(+), 108 deletions(-) delete mode 100644 include/openspace/util/constants.h diff --git a/ext/ghoul b/ext/ghoul index aef83ca794..c8d2a2df4a 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit aef83ca794d1153c8537d19d16222a3a1075d4ab +Subproject commit c8d2a2df4aa62c929fa0dcc648c930956741add4 diff --git a/include/openspace/engine/configurationmanager.h b/include/openspace/engine/configurationmanager.h index c20bf4eedd..d9bb6cb499 100644 --- a/include/openspace/engine/configurationmanager.h +++ b/include/openspace/engine/configurationmanager.h @@ -100,7 +100,6 @@ public: * \return The path to the file that was found with the same base name as \p filename * but higher up in the file structure. * \throw ghoul::RuntimeError If the configuration could not be found - * \pre \p filename must not be empty */ static std::string findConfiguration(const std::string& filename); diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index bab2a4ee05..1a7c971cc7 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -59,6 +59,9 @@ public: }; static const std::string PerformanceMeasurementSharedData; + + static const std::string KeyFontMono; + static const std::string KeyFontLight; RenderEngine(); ~RenderEngine(); diff --git a/include/openspace/util/constants.h b/include/openspace/util/constants.h deleted file mode 100644 index 2c05890afb..0000000000 --- a/include/openspace/util/constants.h +++ /dev/null @@ -1,47 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2015 * - * * - * 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 __CONSTANTS_H__ -#define __CONSTANTS_H__ - -#include - -namespace openspace { -namespace constants { - -namespace fonts { - const std::string keySGCT = "SGCTFont"; - const std::string keyMono = "Mono"; - const std::string keyLight = "Light"; -} // namespace fonts - -namespace scenegraphnode { - const std::string keyName = "Name"; -} // namespace scenegraphnode - -} // namespace constants -} // namespace openspace - - -#endif // __CONSTANTS_H__ \ No newline at end of file diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index f13f9953bb..062169207a 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -72,13 +73,13 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) , _frameCount(0) { std::string name; - bool success = dictionary.getValue(constants::scenegraphnode::keyName, name); + bool success = dictionary.getValue(SceneGraphNode::KeyName, name); ghoul_assert(success, "Name was not passed to RenderableModel"); ghoul::Dictionary geometryDictionary; success = dictionary.getValue(keyGeometry, geometryDictionary); if (success) { - geometryDictionary.setValue(constants::scenegraphnode::keyName, name); + geometryDictionary.setValue(SceneGraphNode::KeyName, name); _geometry = modelgeometry::ModelGeometry::createFromDictionary(geometryDictionary); } diff --git a/modules/base/rendering/renderableplanet.cpp b/modules/base/rendering/renderableplanet.cpp index 84e0f99aa5..70ec4ef995 100644 --- a/modules/base/rendering/renderableplanet.cpp +++ b/modules/base/rendering/renderableplanet.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -65,9 +66,9 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) , _hasNightTexture(false) { std::string name; - bool success = dictionary.getValue(constants::scenegraphnode::keyName, name); + bool success = dictionary.getValue(SceneGraphNode::KeyName, name); ghoul_assert(success, - "RenderablePlanet need the '" < #include #include +#include namespace { const std::string _loggerCat = "SimpleSphereGeometry"; @@ -48,12 +49,11 @@ SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary) , _segments("segments", "Segments", 20, 1, 50) , _sphere(nullptr) { - using constants::scenegraphnode::keyName; using constants::simplespheregeometry::keyRadius; using constants::simplespheregeometry::keySegments; // The name is passed down from the SceneGraphNode - bool success = dictionary.getValue(keyName, _name); + bool success = dictionary.getValue(SceneGraphNode::KeyName, _name); assert(success); glm::vec4 radius; diff --git a/modules/fieldlines/rendering/renderablefieldlines.cpp b/modules/fieldlines/rendering/renderablefieldlines.cpp index 3e82ac773b..025b46977e 100644 --- a/modules/fieldlines/rendering/renderablefieldlines.cpp +++ b/modules/fieldlines/rendering/renderablefieldlines.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -91,12 +92,12 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary) , _vertexPositionBuffer(0) { ghoul_assert( - dictionary.hasKeyAndValue(constants::scenegraphnode::keyName), + dictionary.hasKeyAndValue(SceneGraphNode::KeyName), "Renderable does not have a name" ); std::string name; - dictionary.getValue(constants::scenegraphnode::keyName, name); + dictionary.getValue(SceneGraphNode::KeyName, name); _loggerCat = "RenderableFieldlines [" + name + "]"; diff --git a/modules/newhorizons/rendering/renderablemodelprojection.cpp b/modules/newhorizons/rendering/renderablemodelprojection.cpp index 76472ca906..2ad84751d6 100644 --- a/modules/newhorizons/rendering/renderablemodelprojection.cpp +++ b/modules/newhorizons/rendering/renderablemodelprojection.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include "imgui.h" @@ -91,13 +92,13 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di , _programIsDirty(false) { std::string name; - bool success = dictionary.getValue(constants::scenegraphnode::keyName, name); + bool success = dictionary.getValue(SceneGraphNode::KeyName, name); ghoul_assert(success, "Name was not passed to RenderableModelProjection"); ghoul::Dictionary geometryDictionary; success = dictionary.getValue(keyGeometry, geometryDictionary); if (success) { - geometryDictionary.setValue(constants::scenegraphnode::keyName, name); + geometryDictionary.setValue(SceneGraphNode::KeyName, name); _geometry = modelgeometry::ModelGeometry::createFromDictionary(geometryDictionary); } diff --git a/modules/newhorizons/rendering/renderableplanetprojection.cpp b/modules/newhorizons/rendering/renderableplanetprojection.cpp index 486e5578cb..ab698cf771 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.cpp +++ b/modules/newhorizons/rendering/renderableplanetprojection.cpp @@ -32,6 +32,7 @@ #include //#include #include +#include #include #include @@ -99,7 +100,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& , _clearingImage(absPath("${OPENSPACE_DATA}/scene/common/textures/clear.png")) { std::string name; - bool success = dictionary.getValue(constants::scenegraphnode::keyName, name); + bool success = dictionary.getValue(SceneGraphNode::KeyName, name); ghoul_assert(success, ""); _defaultProjImage = absPath("textures/defaultProj.png"); @@ -108,7 +109,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& success = dictionary.getValue( keyGeometry, geometryDictionary); if (success) { - geometryDictionary.setValue(constants::scenegraphnode::keyName, name); + geometryDictionary.setValue(SceneGraphNode::KeyName, name); _geometry = planetgeometryprojection::PlanetGeometryProjection::createFromDictionary(geometryDictionary); } diff --git a/modules/newhorizons/rendering/simplespheregeometryprojection.cpp b/modules/newhorizons/rendering/simplespheregeometryprojection.cpp index 8d840a70a0..4d48460157 100644 --- a/modules/newhorizons/rendering/simplespheregeometryprojection.cpp +++ b/modules/newhorizons/rendering/simplespheregeometryprojection.cpp @@ -24,6 +24,7 @@ #include #include +#include namespace { const std::string _loggerCat = "SimpleSphereGeometryProjection"; @@ -47,12 +48,11 @@ SimpleSphereGeometryProjection::SimpleSphereGeometryProjection(const ghoul::Dict , _segments("segments", "Segments", 20, 1, 1000) , _planet(nullptr) { - using constants::scenegraphnode::keyName; using constants::simplespheregeometryprojection::keyRadius; using constants::simplespheregeometryprojection::keySegments; // The name is passed down from the SceneGraphNode - bool success = dictionary.getValue(keyName, _name); + bool success = dictionary.getValue(SceneGraphNode::KeyName, _name); assert(success); // removing "Projection"-suffix from name for SPICE compability, TODO: better solution @AA diff --git a/modules/volume/rendering/renderablevolumegl.cpp b/modules/volume/rendering/renderablevolumegl.cpp index 2ff94ce6d7..1a2ee524f0 100644 --- a/modules/volume/rendering/renderablevolumegl.cpp +++ b/modules/volume/rendering/renderablevolumegl.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -68,7 +69,7 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary) , _id(-1) { std::string name; - bool success = dictionary.getValue(constants::scenegraphnode::keyName, name); + bool success = dictionary.getValue(SceneGraphNode::KeyName, name); assert(success); _filename = ""; diff --git a/src/abuffer/abuffervisualizer.cpp b/src/abuffer/abuffervisualizer.cpp index b1082cc521..f109c641bf 100644 --- a/src/abuffer/abuffervisualizer.cpp +++ b/src/abuffer/abuffervisualizer.cpp @@ -140,37 +140,37 @@ void ABufferVisualizer::render() { _pointcloudProgram->deactivate(); - const int font_size_light = 8; - const sgct_text::Font* fontLight = sgct_text::FontManager::instance()->getFont(constants::fonts::keyLight, font_size_light); - - const glm::mat4 scale = glm::scale(glm::mat4(1.0), glm::vec3(0.04, 0.04, 0.04)); - glm::mat4 translate, mvp; - - const glm::mat4 viewProjMatrix = OsEng.windowWrapper().viewProjectionMatrix(); - translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 0, 0)); - mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; - Freetype::print3d(fontLight, mvp, "(0,0,0)"); - translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 0, 1)); - mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; - Freetype::print3d(fontLight, mvp, "(0,0,1)"); - translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 1, 0)); - mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; - Freetype::print3d(fontLight, mvp, "(0,1,0)"); - translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 0, 0)); - mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; - Freetype::print3d(fontLight, mvp, "(1,0,0)"); - translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 1, 1)); - mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; - Freetype::print3d(fontLight, mvp, "(0,1,1)"); - translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 0, 1)); - mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; - Freetype::print3d(fontLight, mvp, "(1,0,1)"); - translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 1, 0)); - mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; - Freetype::print3d(fontLight, mvp, "(1,1,0)"); - translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 1, 1)); - mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; - Freetype::print3d(fontLight, mvp, "(1,1,1)"); +// const int font_size_light = 8; +// const sgct_text::Font* fontLight = sgct_text::FontManager::instance()->getFont(constants::fonts::keyLight, font_size_light); +// +// const glm::mat4 scale = glm::scale(glm::mat4(1.0), glm::vec3(0.04, 0.04, 0.04)); +// glm::mat4 translate, mvp; +// +// const glm::mat4 viewProjMatrix = OsEng.windowWrapper().viewProjectionMatrix(); +// translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 0, 0)); +// mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; +// Freetype::print3d(fontLight, mvp, "(0,0,0)"); +// translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 0, 1)); +// mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; +// Freetype::print3d(fontLight, mvp, "(0,0,1)"); +// translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 1, 0)); +// mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; +// Freetype::print3d(fontLight, mvp, "(0,1,0)"); +// translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 0, 0)); +// mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; +// Freetype::print3d(fontLight, mvp, "(1,0,0)"); +// translate = glm::translate(glm::mat4(1.0), glm::vec3(0, 1, 1)); +// mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; +// Freetype::print3d(fontLight, mvp, "(0,1,1)"); +// translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 0, 1)); +// mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; +// Freetype::print3d(fontLight, mvp, "(1,0,1)"); +// translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 1, 0)); +// mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; +// Freetype::print3d(fontLight, mvp, "(1,1,0)"); +// translate = glm::translate(glm::mat4(1.0), glm::vec3(1, 1, 1)); +// mvp = viewProjMatrix*modelMatrix*translate*rotationText*scale; +// Freetype::print3d(fontLight, mvp, "(1,1,1)"); } void ABufferVisualizer::initializeMarkers() { diff --git a/src/engine/configurationmanager.cpp b/src/engine/configurationmanager.cpp index d4c713f3ff..12afb65fa7 100644 --- a/src/engine/configurationmanager.cpp +++ b/src/engine/configurationmanager.cpp @@ -65,8 +65,6 @@ const string ConfigurationManager::KeyDisableMasterRendering = "DisableRendering const string ConfigurationManager::KeyDownloadRequestURL = "DownloadRequestURL"; string ConfigurationManager::findConfiguration(const string& filename) { - ghoul_assert(!filename.empty(), "Filename must not be empty"); - using ghoul::filesystem::Directory; Directory directory = FileSys.currentDirectory(); diff --git a/src/interaction/luaconsole.cpp b/src/interaction/luaconsole.cpp index 38076ee860..fed9010af4 100644 --- a/src/interaction/luaconsole.cpp +++ b/src/interaction/luaconsole.cpp @@ -32,6 +32,9 @@ #include #include #include +#include +#include +#include #include #include @@ -294,9 +297,16 @@ void LuaConsole::render() { const glm::vec4 red(1, 0, 0, 1); const glm::vec4 green(0, 1, 0, 1); const glm::vec4 white(1, 1, 1, 1); - const sgct_text::Font* font = sgct_text::FontManager::instance()->getFont(constants::fonts::keyMono, static_cast(font_size)); - sgct_text::print(font, 15.0f, startY, red, "$"); - sgct_text::print(font, 15.0f + font_size, startY, white, "%s", _commands.at(_activeCommand).c_str()); + std::shared_ptr font = OsEng.fontManager().font("Mono", font_size); +// const sgct_text::Font* font = sgct_text::FontManager::instance()->getFont(constants::fonts::keyMono, static_cast(font_size)); + + using ghoul::fontrendering::RenderFont; + + RenderFont(*font, glm::vec2(15.f, startY), red, "$"); + RenderFont(*font, glm::vec2(15.f + font_size, startY), white, "%s", _commands.at(_activeCommand).c_str()); + +// sgct_text::print(font, 15.0f, startY, red, "$"); +// sgct_text::print(font, 15.0f + font_size, startY, white, "%s", _commands.at(_activeCommand).c_str()); size_t n = std::count(_commands.at(_activeCommand).begin(), _commands.at(_activeCommand).begin() + _inputPosition, '\n'); size_t p = _commands.at(_activeCommand).find_last_of('\n', _inputPosition); @@ -319,7 +329,9 @@ void LuaConsole::render() { std::stringstream ss; ss << "%" << linepos + 1 << "s"; - sgct_text::print(font, 15.0f + font_size*0.5f, startY - (font_size)*(n + 1)*3.0f / 2.0f, green, ss.str().c_str(), "^"); + RenderFont(*font, glm::vec2(15.f + font_size * 0.5f, startY - (font_size)*(n + 1)*3.0f / 2.0f), green, ss.str().c_str(), "^"); + +// sgct_text::print(font, 15.0f + font_size*0.5f, startY - (font_size)*(n + 1)*3.0f / 2.0f, green, ss.str().c_str(), "^"); } Key LuaConsole::commandInputButton() { diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 31d1d1e66a..eabf3a940b 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -28,6 +28,7 @@ #include #include #include +#include // ghoul #include @@ -48,7 +49,7 @@ namespace openspace { Renderable* Renderable::createFromDictionary(const ghoul::Dictionary& dictionary) { // The name is passed down from the SceneGraphNode std::string name; - bool success = dictionary.getValue(constants::scenegraphnode::keyName, name); + bool success = dictionary.getValue(SceneGraphNode::KeyName, name); assert(success); std::string renderableType; @@ -80,8 +81,8 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary) setName("renderable"); #ifndef NDEBUG std::string name; - ghoul_assert(dictionary.getValue(constants::scenegraphnode::keyName, name), - "Scenegraphnode need to specify '" << constants::scenegraphnode::keyName + ghoul_assert(dictionary.getValue(SceneGraphNode::KeyName, name), + "Scenegraphnode need to specify '" << SceneGraphNode::KeyName << "' because renderables is going to use this for debugging!"); #endif diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index e249ce9d8b..9cee5b231c 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -94,6 +94,9 @@ namespace openspace { const std::string RenderEngine::PerformanceMeasurementSharedData = "OpenSpacePerformanceMeasurementSharedData"; +const std::string RenderEngine::KeyFontMono = "Mono"; +const std::string RenderEngine::KeyFontLight = "Light"; + RenderEngine::RenderEngine() : _mainCamera(nullptr) , _sceneGraph(nullptr) @@ -207,11 +210,11 @@ bool RenderEngine::initializeGL() { const float fontSizeTime = 15.f; - _fontDate = OsEng.fontManager().font(constants::fonts::keyMono, fontSizeTime); + _fontDate = OsEng.fontManager().font(KeyFontMono, fontSizeTime); const float fontSizeMono = 10.f; - _fontInfo = OsEng.fontManager().font(constants::fonts::keyMono, fontSizeMono); + _fontInfo = OsEng.fontManager().font(KeyFontMono, fontSizeMono); const float fontSizeLight = 8.f; - _fontLog = OsEng.fontManager().font(constants::fonts::keyLight, fontSizeLight); + _fontLog = OsEng.fontManager().font(KeyFontLight, fontSizeLight);