perform render thumbnail only if framebuffer available

This commit is contained in:
Bruno
2021-04-28 11:23:11 +02:00
parent 7b7bd763c9
commit a28f46a9eb

View File

@@ -76,47 +76,42 @@ void RenderView::draw()
scene.root()->draw(glm::identity<glm::mat4>(), P); scene.root()->draw(glm::identity<glm::mat4>(), P);
fading_overlay_->draw(glm::identity<glm::mat4>(), projection); fading_overlay_->draw(glm::identity<glm::mat4>(), projection);
frame_buffer_->end(); frame_buffer_->end();
}
// if a thumbnailer is pending // if a thumbnailer is pending
if (thumbnailer_.size() > 0) { if (thumbnailer_.size() > 0) {
try { try {
// promise will fail if no framebuffer // new thumbnailing framebuffer
if ( frame_buffer_ == nullptr ) FrameBuffer *frame_thumbnail = new FrameBuffer( glm::vec3(SESSION_THUMBNAIL_HEIGHT * frame_buffer_->aspectRatio(), SESSION_THUMBNAIL_HEIGHT, 1.f) );
throw std::runtime_error("no frame");
// new thumbnailing framebuffer // render
FrameBuffer *frame_thumbnail = new FrameBuffer( glm::vec3(SESSION_THUMBNAIL_HEIGHT * frame_buffer_->aspectRatio(), SESSION_THUMBNAIL_HEIGHT, 1.f) ); if (Settings::application.render.blit) {
if ( !frame_buffer_->blit(frame_thumbnail) )
throw std::runtime_error("no blit");
}
else {
FrameBufferSurface *thumb = new FrameBufferSurface(frame_buffer_);
frame_thumbnail->begin();
thumb->draw(glm::identity<glm::mat4>(), frame_thumbnail->projection());
frame_thumbnail->end();
delete thumb;
}
// render // return valid thumbnail promise
if (Settings::application.render.blit) { thumbnailer_.front().set_value( frame_thumbnail->image() );
if ( !frame_buffer_->blit(frame_thumbnail) )
throw std::runtime_error("no blit"); // done with thumbnailing framebuffer
delete frame_thumbnail;
} }
else { catch(...) {
FrameBufferSurface *thumb = new FrameBufferSurface(frame_buffer_); // return failed thumbnail promise
frame_thumbnail->begin(); thumbnailer_.front().set_exception(std::current_exception());
thumb->draw(glm::identity<glm::mat4>(), frame_thumbnail->projection());
frame_thumbnail->end();
delete thumb;
} }
// return valid thumbnail promise // done with this promise
thumbnailer_.front().set_value( frame_thumbnail->image() ); thumbnailer_.pop_back();
// done with thumbnailing framebuffer
delete frame_thumbnail;
} }
catch(...) {
// return failed thumbnail promise
thumbnailer_.front().set_exception(std::current_exception());
}
// done with this promise
thumbnailer_.pop_back();
} }
} }
@@ -136,7 +131,8 @@ FrameBufferImage *RenderView::thumbnail ()
img = t.get(); img = t.get();
} }
// catch any failed promise // catch any failed promise
catch (std::runtime_error&){ } catch (std::runtime_error&){
}
return img; return img;
} }