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/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 5ec244ebf7..8c77deef34 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -231,17 +231,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; @@ -249,9 +249,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); @@ -271,7 +269,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++; @@ -286,7 +283,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?"); } } @@ -336,8 +333,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; @@ -350,19 +349,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(); @@ -373,15 +379,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 6632cb89db..2d3b9d5e1b 100644 --- a/modules/iswa/rendering/textureplane.cpp +++ b/modules/iswa/rendering/textureplane.cpp @@ -154,7 +154,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")); @@ -168,18 +168,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(); 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 998db29cbb..aca151a505 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -204,7 +204,7 @@ namespace openspace{ }else if ((*it)->type == "DATA"){ createPlane((*it)->id,(*it)->json,std::string("DataPlane")); } else { - LDEBUG("\""+ (*it)->type + "\" is not a valid type"); + LERROR("\""+ (*it)->type + "\" is not a valid type"); } it = _metaFutures.erase( it ); }else{