Remove constants.h file

Reenable LuaConsole rendering
This commit is contained in:
Alexander Bock
2015-12-14 17:21:22 -08:00
parent c99666e75a
commit c92fc923f9
17 changed files with 83 additions and 108 deletions

View File

@@ -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);

View File

@@ -59,6 +59,9 @@ public:
};
static const std::string PerformanceMeasurementSharedData;
static const std::string KeyFontMono;
static const std::string KeyFontLight;
RenderEngine();
~RenderEngine();

View File

@@ -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 <string>
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__

View File

@@ -34,6 +34,7 @@
#include <ghoul/io/texture/texturereader.h>
#include <ghoul/opengl/textureunit.h>
#include <ghoul/filesystem/filesystem.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>
@@ -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);
}

View File

@@ -31,6 +31,7 @@
#include <openspace/util/constants.h>
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>
#include <openspace/scene/scenegraphnode.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/misc/assert.h>
@@ -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 '" <<constants::scenegraphnode::keyName<<"' be specified");
"RenderablePlanet need the '" << SceneGraphNode::KeyName<<"' be specified");
//std::string path;
//success = dictionary.getValue(constants::scenegraph::keyPathModule, path);
@@ -77,7 +78,7 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
ghoul::Dictionary geometryDictionary;
success = dictionary.getValue(keyGeometry, geometryDictionary);
if (success) {
geometryDictionary.setValue(constants::scenegraphnode::keyName, name);
geometryDictionary.setValue(SceneGraphNode::KeyName, name);
//geometryDictionary.setValue(constants::scenegraph::keyPathModule, path);
_geometry = planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary);
}

View File

@@ -25,6 +25,7 @@
#include <modules/base/rendering/simplespheregeometry.h>
#include <openspace/util/constants.h>
#include <openspace/util/powerscaledsphere.h>
#include <openspace/scene/scenegraphnode.h>
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;

View File

@@ -27,6 +27,7 @@
#include <openspace/util/powerscaledcoordinate.h>
#include <modules/kameleon/include/kameleonwrapper.h>
#include <openspace/util/constants.h>
#include <openspace/scene/scenegraphnode.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/filesystem/file.h>
@@ -91,12 +92,12 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
, _vertexPositionBuffer(0)
{
ghoul_assert(
dictionary.hasKeyAndValue<std::string>(constants::scenegraphnode::keyName),
dictionary.hasKeyAndValue<std::string>(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 + "]";

View File

@@ -32,6 +32,7 @@
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/engine/openspaceengine.h>
#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);
}

View File

@@ -32,6 +32,7 @@
#include <ghoul/io/texture/texturereader.h>
//#include <ghoul/opengl/textureunit.h>
#include <ghoul/filesystem/filesystem.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>
@@ -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);
}

View File

@@ -24,6 +24,7 @@
#include <modules/newhorizons/rendering/simplespheregeometryprojection.h>
#include <openspace/util/constants.h>
#include <openspace/scene/scenegraphnode.h>
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

View File

@@ -30,6 +30,7 @@
#include <openspace/rendering/renderengine.h>
#include <modules/kameleon/include/kameleonwrapper.h>
#include <openspace/util/constants.h>
#include <openspace/scene/scenegraphnode.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/filesystem/file.h>
@@ -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 = "";

View File

@@ -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() {

View File

@@ -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();

View File

@@ -32,6 +32,9 @@
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/clipboard.h>
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/font/font.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
#include <string>
#include <iostream>
@@ -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<int>(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<ghoul::fontrendering::Font> font = OsEng.fontManager().font("Mono", font_size);
// const sgct_text::Font* font = sgct_text::FontManager::instance()->getFont(constants::fonts::keyMono, static_cast<int>(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() {

View File

@@ -28,6 +28,7 @@
#include <openspace/util/factorymanager.h>
#include <openspace/util/updatestructures.h>
#include <openspace/util/spicemanager.h>
#include <openspace/scene/scenegraphnode.h>
// ghoul
#include <ghoul/misc/dictionary.h>
@@ -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

View File

@@ -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);