mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-21 12:29:04 -06:00
isReady check before render of iSWACygnets
This commit is contained in:
@@ -38,7 +38,7 @@ public:
|
||||
virtual bool initialize();
|
||||
virtual bool deinitialize();
|
||||
|
||||
bool isReady();
|
||||
bool isReady() override;
|
||||
|
||||
virtual void render();
|
||||
virtual void update();
|
||||
|
||||
@@ -65,7 +65,7 @@ bool ISWAContainer::isReady() const { return true; }
|
||||
|
||||
void ISWAContainer::render(const RenderData& data){
|
||||
for(auto iSWACygnet : _iSWACygnets){
|
||||
if(iSWACygnet->enabled()){
|
||||
if(iSWACygnet->enabled() && iSWACygnet->isReady()){
|
||||
iSWACygnet->render();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
virtual void update();
|
||||
|
||||
bool enabled(){return _enabled.value();}
|
||||
virtual bool isReady() = 0;
|
||||
|
||||
protected:
|
||||
void setPscUniforms(ghoul::opengl::ProgramObject* program, const Camera* camera, const PowerScaledCoordinate& position);
|
||||
|
||||
@@ -65,12 +65,13 @@ bool ScreenSpaceCygnet::initialize(){
|
||||
createPlane();
|
||||
createShaders();
|
||||
|
||||
loadTexture();
|
||||
updateTexture();
|
||||
|
||||
// Setting spherical/euclidean onchange handler
|
||||
_useFlatScreen.onChange([this](){
|
||||
useEuclideanCoordinates(_useFlatScreen.value());
|
||||
});
|
||||
|
||||
return isReady();
|
||||
}
|
||||
|
||||
@@ -96,6 +97,9 @@ bool ScreenSpaceCygnet::deinitialize(){
|
||||
}
|
||||
|
||||
void ScreenSpaceCygnet::render(){
|
||||
|
||||
if(!isReady()) return;
|
||||
|
||||
glm::mat4 rotation = rotationMatrix();
|
||||
glm::mat4 translation = translationMatrix();
|
||||
glm::mat4 scale = scaleMatrix();
|
||||
@@ -129,7 +133,12 @@ void ScreenSpaceCygnet::updateTexture(){
|
||||
}
|
||||
|
||||
bool ScreenSpaceCygnet::isReady() const{
|
||||
return true;
|
||||
bool ready = true;
|
||||
if (!_shader)
|
||||
ready &= false;
|
||||
if(!_texture)
|
||||
ready &= false;
|
||||
return ready;
|
||||
}
|
||||
|
||||
void ScreenSpaceCygnet::loadTexture() {
|
||||
|
||||
@@ -52,8 +52,7 @@ TexturePlane::TexturePlane()
|
||||
_fileExtension = ISWAManager::ref().fileExtension(_cygnetId.value());
|
||||
_path = "${OPENSPACE_DATA}/"+ name()+_fileExtension;
|
||||
|
||||
updateTexture();
|
||||
|
||||
|
||||
_cygnetId.onChange([this](){
|
||||
_fileExtension = ISWAManager::ref().fileExtension(_cygnetId.value());
|
||||
_path = "${OPENSPACE_DATA}/"+ name()+_fileExtension;
|
||||
@@ -71,9 +70,9 @@ bool TexturePlane::initialize(){
|
||||
_pscOffset = glm::vec4(0, 0, 0, 1);
|
||||
|
||||
CygnetPlane::initialize();
|
||||
|
||||
loadTexture();
|
||||
|
||||
|
||||
updateTexture();
|
||||
|
||||
return isReady();
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,6 @@ protected:
|
||||
|
||||
TEST_F(ScreenSpaceRenderableTest, initialize){
|
||||
bool isReady = _ssr.isReady();
|
||||
_ssr._texturePath;
|
||||
ASSERT_TRUE(!isReady) << "ScreenSpaceImage is ready before initialize";
|
||||
|
||||
// cannot test initialize, crashes at createplane becasue of opengl functions. needs mocking
|
||||
|
||||
Reference in New Issue
Block a user