From cb49805b07876896c8f23089e1704284e0322dcd Mon Sep 17 00:00:00 2001 From: Sebastian Piwell Date: Wed, 20 Apr 2016 10:28:53 -0400 Subject: [PATCH 1/2] Update ghoul --- ext/ghoul | 2 +- modules/base/shaders/screnspace_fs.glsl | 2 +- modules/iswa/rendering/dataplane.cpp | 2 +- modules/iswa/shaders/cygnetplane_fs.glsl | 2 +- modules/iswa/shaders/dataplane_fs.glsl | 2 +- modules/iswa/util/iswamanager.cpp | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index ba88e7fb74..ef1063b4af 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit ba88e7fb74a17fc00a698f6ecb6ac3640cb14472 +Subproject commit ef1063b4afb99826e7c254b2e7f9ed79f5bd600c diff --git a/modules/base/shaders/screnspace_fs.glsl b/modules/base/shaders/screnspace_fs.glsl index ad7a750781..1f8a8966f3 100644 --- a/modules/base/shaders/screnspace_fs.glsl +++ b/modules/base/shaders/screnspace_fs.glsl @@ -39,7 +39,7 @@ Fragment getFragment(){ // power scale coordinates for depth. w value is set to 1.0. float depth = (1.0 + log(abs(OcclusionDepth) + 1/pow(k, 1.0))/log(k)) / 27.0; - frag.color = texture(texture1, vs_st); + frag.color = texture(texture1, vec2(vs_st.s, 1-vs_st.t)); frag.color.a = (frag.color.a != 0.0f) ? Alpha : frag.color.a; if(frag.color.a == 0.0f){ discard; diff --git a/modules/iswa/rendering/dataplane.cpp b/modules/iswa/rendering/dataplane.cpp index d7766e8dfa..36d0a5bb81 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -376,7 +376,7 @@ void DataPlane::loadTexture() { void DataPlane::updateTexture(){ _memorybuffer = ""; - std::shared_ptr future = ISWAManager::ref().downloadDataToMemory(2, _memorybuffer); + std::shared_ptr future = ISWAManager::ref().downloadDataToMemory(-_data->id, _memorybuffer); if(future){ _futureData = future; diff --git a/modules/iswa/shaders/cygnetplane_fs.glsl b/modules/iswa/shaders/cygnetplane_fs.glsl index f5a21a87f8..0df9996a11 100644 --- a/modules/iswa/shaders/cygnetplane_fs.glsl +++ b/modules/iswa/shaders/cygnetplane_fs.glsl @@ -35,7 +35,7 @@ Fragment getFragment() { vec4 position = vs_position; float depth = pscDepth(position); vec4 diffuse; - diffuse = texture(texture1, vs_st); + diffuse = texture(texture1, vec2(vs_st.s, 1-vs_st.t)); //vec4 diffuse = vec4(1,vs_st,1); //vec4 diffuse = vec4(1,0,0,1); diff --git a/modules/iswa/shaders/dataplane_fs.glsl b/modules/iswa/shaders/dataplane_fs.glsl index 16a5174827..0da2e62fdd 100644 --- a/modules/iswa/shaders/dataplane_fs.glsl +++ b/modules/iswa/shaders/dataplane_fs.glsl @@ -41,7 +41,7 @@ Fragment getFragment() { float depth = pscDepth(position); vec4 diffuse; // diffuse = top; - diffuse = texture(texture1, vs_st); + diffuse = texture(texture1, vec2(vs_st.s, 1-vs_st.t)); //float v = texture(texture1, vs_st).r; //float x = tfValues.x; //float y = tfValues.y; diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index 1f8a5822df..4243940528 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -219,10 +219,10 @@ namespace openspace{ void ISWAManager::update(){ for (auto it = _metaFutures.begin(); it != _metaFutures.end(); ){ if((*it)->isFinished) { - if((*it)->type == "TEXTURE"){ - createPlane((*it)->id,(*it)->json,std::string("TexturePlane")); - }else{ + if((*it)->type == "DATA"){ createPlane((*it)->id,(*it)->json,std::string("DataPlane")); + }else{ + createPlane((*it)->id,(*it)->json,std::string("TexturePlane")); } it = _metaFutures.erase( it ); From 7b510dae980cabde5d33894077a42239600f618e Mon Sep 17 00:00:00 2001 From: Sebastian Piwell Date: Wed, 20 Apr 2016 10:48:49 -0400 Subject: [PATCH 2/2] Add dataplane when time is running --- modules/iswa/rendering/cygnetplane.h | 4 +-- modules/iswa/rendering/dataplane.cpp | 46 +++++++++++++++---------- modules/iswa/rendering/dataplane.h | 4 +-- modules/iswa/rendering/textureplane.cpp | 12 +++++-- modules/iswa/rendering/textureplane.h | 4 +-- 5 files changed, 44 insertions(+), 26 deletions(-) diff --git a/modules/iswa/rendering/cygnetplane.h b/modules/iswa/rendering/cygnetplane.h index 4117a33ea6..99bc620859 100644 --- a/modules/iswa/rendering/cygnetplane.h +++ b/modules/iswa/rendering/cygnetplane.h @@ -38,8 +38,8 @@ public: virtual bool isReady() const override; protected: - virtual void loadTexture() = 0; - virtual void updateTexture() = 0; + virtual bool loadTexture() = 0; + virtual bool updateTexture() = 0; void createPlane(); void destroyPlane(); diff --git a/modules/iswa/rendering/dataplane.cpp b/modules/iswa/rendering/dataplane.cpp index 36d0a5bb81..8e4297d03d 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -230,17 +230,17 @@ void DataPlane::update(const UpdateData& data){ } } - if(_futureData && _futureData->isFinished){ + if(_futureData && _futureData->isFinished && _memorybuffer != ""){ if(!_dataOptions.options().size()){ readHeader(); } - loadTexture(); - _futureData = nullptr; + + if(loadTexture()) + _futureData = nullptr; } } void DataPlane::readHeader(){ - // std::cout << "In the read header function" << std::endl; if(!_memorybuffer.empty()){ std::stringstream memorystream(_memorybuffer); std::string line; @@ -248,9 +248,7 @@ void DataPlane::readHeader(){ int numOptions = 0; while(getline(memorystream,line)){ if(line.find("#") == 0){ - // std::cout << "Comment line" << std::endl; if(line.find("# Output data:") == 0){ - // std::cout << "the line with the good stuff" << std::endl; line = line.substr(26); std::stringstream ss(line); @@ -270,7 +268,6 @@ void DataPlane::readHeader(){ ss = std::stringstream(line); std::string option; while(ss >> option){ - // std::cout << option << std::endl; if(option != "x" && option != "y" && option != "z"){ _dataOptions.addOption({numDataOptions, option}); numDataOptions++; @@ -285,7 +282,7 @@ void DataPlane::readHeader(){ } } }else{ - LERROR("Noting in memory buffer, are you connected to the information super highway?"); + LWARNING("Noting in memory buffer, are you connected to the information super highway?"); } } @@ -335,8 +332,10 @@ float* DataPlane::readData(){ } } - if(numValues != _dimensions.x*_dimensions.y) - LERROR("Number of values read and expected are not the same"); + if(numValues != _dimensions.x*_dimensions.y){ + LWARNING("Number of values read and expected are not the same"); + return nullptr; + } for(int i=0; i< numValues; i++){ combinedValues[i] = 0; @@ -349,19 +348,26 @@ float* DataPlane::readData(){ return combinedValues; }else{ - LERROR("Noting in memory buffer, are you connected to the information super highway?"); + LWARNING("Noting in memory buffer, are you connected to the information super highway?"); } } -void DataPlane::loadTexture() { +bool DataPlane::loadTexture() { float* values = readData(); + if(!values){ + return false; + } if (!_texture) { - ghoul::opengl::Texture::FilterMode filtermode = ghoul::opengl::Texture::FilterMode::Linear; - ghoul::opengl::Texture::WrappingMode wrappingmode = ghoul::opengl::Texture::WrappingMode::ClampToEdge; - - std::unique_ptr texture = - std::make_unique(values, _dimensions, ghoul::opengl::Texture::Format::Red, GL_RED, GL_FLOAT, filtermode, wrappingmode); + std::unique_ptr texture = std::make_unique( + values, + _dimensions, + ghoul::opengl::Texture::Format::Red, + GL_RED, + GL_FLOAT, + ghoul::opengl::Texture::FilterMode::Linear, + ghoul::opengl::Texture::WrappingMode::ClampToEdge + ); if(texture){ texture->uploadTexture(); @@ -372,15 +378,19 @@ void DataPlane::loadTexture() { _texture->setPixelData(values); _texture->uploadTexture(); } + return true; } -void DataPlane::updateTexture(){ +bool DataPlane::updateTexture(){ _memorybuffer = ""; std::shared_ptr future = ISWAManager::ref().downloadDataToMemory(-_data->id, _memorybuffer); if(future){ _futureData = future; + return (_memorybuffer != ""); } + + return false; } int DataPlane::id(){ diff --git a/modules/iswa/rendering/dataplane.h b/modules/iswa/rendering/dataplane.h index 9de537ff54..e2e767e123 100644 --- a/modules/iswa/rendering/dataplane.h +++ b/modules/iswa/rendering/dataplane.h @@ -44,8 +44,8 @@ class DataPlane : public CygnetPlane { virtual void update(const UpdateData& data) override; private: - virtual void loadTexture() override; - virtual void updateTexture() override; + virtual bool loadTexture() override; + virtual bool updateTexture() override; void readHeader(); float* readData(); diff --git a/modules/iswa/rendering/textureplane.cpp b/modules/iswa/rendering/textureplane.cpp index 8a184ef6da..23d861a7e5 100644 --- a/modules/iswa/rendering/textureplane.cpp +++ b/modules/iswa/rendering/textureplane.cpp @@ -151,7 +151,7 @@ void TexturePlane::update(const UpdateData& data){ } } -void TexturePlane::loadTexture() { +bool TexturePlane::loadTexture() { // std::cout << _data->path << std::endl; // std::unique_ptr texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_data->path)); //std::unique_ptr texture = ghoul::io::TextureReader::ref().loadTexture(absPath("${OPENSPACE_DATA}/GM_openspace_Z0_20150315_000000.png")); @@ -165,18 +165,26 @@ void TexturePlane::loadTexture() { texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); _texture = std::move(texture); + + return true; } } + + return false; } -void TexturePlane::updateTexture(){ +bool TexturePlane::updateTexture(){ _memorybuffer = ""; std::shared_ptr future = ISWAManager::ref().downloadImageToMemory(_data->id, _memorybuffer); // std::shared_ptr future = ISWAManager::ref().downloadImage(_data->id, absPath(_data->path)); if(future){ _futureTexture = future; + + return true; } + + return false; } int TexturePlane::id(){ diff --git a/modules/iswa/rendering/textureplane.h b/modules/iswa/rendering/textureplane.h index a5f9c50588..b35bef3fcb 100644 --- a/modules/iswa/rendering/textureplane.h +++ b/modules/iswa/rendering/textureplane.h @@ -43,8 +43,8 @@ virtual void update(const UpdateData& data) override; private: - virtual void loadTexture() override; - virtual void updateTexture() override; + virtual bool loadTexture() override; + virtual bool updateTexture() override; static int id();