diff --git a/ext/ghoul b/ext/ghoul index 1a05da7f5c..48bd2ef9a3 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 1a05da7f5c345bf69894bacadf1783df9b081be8 +Subproject commit 48bd2ef9a32498be7dd5c7261561f6257342d6ec diff --git a/include/openspace/rendering/stars/renderablestars.h b/include/openspace/rendering/stars/renderablestars.h index 445b9b219c..b4c7ff5093 100644 --- a/include/openspace/rendering/stars/renderablestars.h +++ b/include/openspace/rendering/stars/renderablestars.h @@ -47,33 +47,40 @@ public: void update(const UpdateData& data) override; private: - class DataSource { - public: - const std::vector& data() const; + //class DataSource { + //public: + // const std::vector& data() const; - virtual bool loadData() = 0; + // virtual bool loadData() = 0; - protected: - std::vector _data; - }; + //protected: + // std::vector _data; + //}; - class SpeckDataSource : public DataSource { - public: - SpeckDataSource(const ghoul::Dictionary& dictionary); + //class SpeckDataSource : public DataSource { + //public: + // SpeckDataSource(const ghoul::Dictionary& dictionary); - bool loadData() override; + // bool loadData() override; - private: - bool readSpeckFile(); - bool loadCachedFile(const std::string& file); - bool saveCachedFile(const std::string& file) const; + //private: + // bool readSpeckFile(); + // bool loadCachedFile(const std::string& file); + // bool saveCachedFile(const std::string& file) const; - std::string _file; - }; + // std::string _file; + //}; void loadTexture(); + const std::vector& data() const; + + bool loadData(); + bool readSpeckFile(); + bool loadCachedFile(const std::string& file); + bool saveCachedFile(const std::string& file) const; + void generateBufferObjects(const void* data); properties::StringProperty _colorTexturePath; @@ -85,7 +92,7 @@ private: std::string _speckPath; - DataSource* _source; + std::vector _data; //GLint vertsToDraw; diff --git a/include/openspace/util/constants.h b/include/openspace/util/constants.h index 57d0a55d9d..92c1ce7ee3 100644 --- a/include/openspace/util/constants.h +++ b/include/openspace/util/constants.h @@ -88,13 +88,8 @@ namespace modelgeometry { } // namespace modelgeometry namespace renderablestars { - const std::string keyDataSource = "DataSource"; + const std::string keyFile = "File"; const std::string keyTexture = "Texture"; - - namespace datasource { - const std::string keyType = "Type"; - const std::string keyFile = "File"; - } // namespace datasource } // namespace renderablestars namespace renderablevolumegl { diff --git a/openspace-data b/openspace-data index 3dc211027b..65ac894014 160000 --- a/openspace-data +++ b/openspace-data @@ -1 +1 @@ -Subproject commit 3dc211027b3668e0cfd37bf1f6c7c0dec09a62e8 +Subproject commit 65ac8940144d28dc7d2669cad40ce0abe0ab62fb diff --git a/src/rendering/stars/renderablestars.cpp b/src/rendering/stars/renderablestars.cpp index 8473a40117..7a9b0d318a 100644 --- a/src/rendering/stars/renderablestars.cpp +++ b/src/rendering/stars/renderablestars.cpp @@ -46,7 +46,6 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) , _haloProgram(nullptr) , _pointProgram(nullptr) , _texture(nullptr) - , _source(nullptr) { std::string texturePath = ""; if (dictionary.hasKey(constants::renderablestars::keyTexture)) { @@ -54,25 +53,13 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) _colorTexturePath = absPath(texturePath); } - ghoul::TemplateFactory sourceFactory; - sourceFactory.registerClass("Speck"); - - ghoul::Dictionary sourceDictionary; - bool success = dictionary.getValue(constants::renderablestars::keyDataSource, - sourceDictionary); + bool success = dictionary.getValue(constants::renderablestars::keyFile, _speckPath); if (!success) { - LERROR("RenderableStars did not have key '" << - constants::renderablestars::keyDataSource << "'"); + LERROR("SpeckDataSource did not contain key '" << + constants::renderablestars::keyFile << "'"); return; } - std::string type = ""; - success = sourceDictionary.getValue(constants::renderablestars::datasource::keyType, type); - if (!success) { - LERROR("DataSource did not have key '" << constants::renderablestars::datasource::keyType << "'"); - return; - } - - _source = sourceFactory.create(type, sourceDictionary); + _speckPath = absPath(_speckPath); addProperty(_colorTexturePath); _colorTexturePath.onChange(std::bind(&RenderableStars::loadTexture, this)); @@ -118,7 +105,7 @@ void RenderableStars::generateBufferObjects(const void* data){ glBindVertexArray(0); } -bool RenderableStars::initialize(){ +bool RenderableStars::initialize() { bool completeSuccess = true; // 1. StarProgram - Generates quads with png image of halo @@ -129,9 +116,8 @@ bool RenderableStars::initialize(){ if (_pointProgram == nullptr) completeSuccess &= OsEng.ref().configurationManager().getValue("PointProgram", _pointProgram); - completeSuccess &= _source->loadData(); - - const std::vector& data = _source->data(); + completeSuccess &= loadData(); + const std::vector& data = this->data(); v_stride = 7; // stride in VBO, set manually for now. v_size = static_cast(data.size()); // size of VBO @@ -256,25 +242,26 @@ void RenderableStars::update(const UpdateData& data) } - -const std::vector& RenderableStars::DataSource::data() const { +const std::vector& RenderableStars::data() const { return _data; } -RenderableStars::SpeckDataSource::SpeckDataSource(const ghoul::Dictionary& dictionary) - : DataSource() - , _file("") -{ - bool success = dictionary.getValue(constants::renderablestars::datasource::keyFile, _file); - if (!success) { - LERROR("SpeckDataSource did not contain key '" << - constants::renderablestars::datasource::keyFile << "'"); - return; - } - _file = absPath(_file); -} -bool RenderableStars::SpeckDataSource::loadData() { +//RenderableStars::SpeckDataSource(const ghoul::Dictionary& dictionary) +// : DataSource() +// , _file("") +//{ +// bool success = dictionary.getValue(constants::renderablestars::datasource::keyFile, _file); +// if (!success) { +// LERROR("SpeckDataSource did not contain key '" << +// constants::renderablestars::datasource::keyFile << "'"); +// return; +// } +// _file = absPath(_file); +//} + +bool RenderableStars::loadData() { + std::string _file = _speckPath; std::string cachedFile = ""; FileSys.cacheManager()->getCachedFile(_file, cachedFile, true); @@ -305,7 +292,8 @@ bool RenderableStars::SpeckDataSource::loadData() { return success; } -bool RenderableStars::SpeckDataSource::readSpeckFile() { +bool RenderableStars::readSpeckFile() { + std::string _file = _speckPath; std::ifstream file(_file); if (!file.good()) { LERROR("Failed to open Speck file '" << _file << "'"); @@ -390,7 +378,7 @@ bool RenderableStars::SpeckDataSource::readSpeckFile() { return true; } -bool RenderableStars::SpeckDataSource::loadCachedFile(const std::string& file) { +bool RenderableStars::loadCachedFile(const std::string& file) { std::ifstream fileStream(file, std::ifstream::binary); if (fileStream.good()) { int32_t nValues = 0; @@ -408,7 +396,7 @@ bool RenderableStars::SpeckDataSource::loadCachedFile(const std::string& file) { } } -bool RenderableStars::SpeckDataSource::saveCachedFile(const std::string& file) const { +bool RenderableStars::saveCachedFile(const std::string& file) const { std::ofstream fileStream(file, std::ofstream::binary); if (fileStream.good()) { int32_t nValues = static_cast(_data.size());