mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
perform render thumbnail only if framebuffer available
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user