diff --git a/RenderView.cpp b/RenderView.cpp index 4d9edc3..f5e57e0 100644 --- a/RenderView.cpp +++ b/RenderView.cpp @@ -75,7 +75,12 @@ void RenderView::draw() scene.root()->draw(glm::identity(), P); fading_overlay_->draw(glm::identity(), projection); frame_buffer_->end(); + } +} +void RenderView::drawThumbnail() +{ + if (frame_buffer_) { // if a thumbnailer is pending if (thumbnailer_.size() > 0) { @@ -97,14 +102,14 @@ void RenderView::draw() } // return valid thumbnail promise - thumbnailer_.front().set_value( frame_thumbnail->image() ); + thumbnailer_.back().set_value( frame_thumbnail->image() ); // done with thumbnailing framebuffer delete frame_thumbnail; } catch(...) { // return failed thumbnail promise - thumbnailer_.front().set_exception(std::current_exception()); + thumbnailer_.back().set_exception(std::current_exception()); } // done with this promise @@ -113,7 +118,6 @@ void RenderView::draw() } } - FrameBufferImage *RenderView::thumbnail () { // by default null image diff --git a/RenderView.h b/RenderView.h index cf3d38e..7a2a7f1 100644 --- a/RenderView.h +++ b/RenderView.h @@ -19,6 +19,7 @@ public: RenderView (); ~RenderView (); + // render frame (in opengl context) void draw () override; bool canSelect(Source *) override { return false; } @@ -28,9 +29,11 @@ public: void setFading(float f = 0.f); float fading() const; + // current frame inline FrameBuffer *frame () const { return frame_buffer_; } - // get a thumbnail; wait for a promise to be fullfiled + // get a thumbnail outside of opengl context; wait for a promise to be fullfiled after draw + void drawThumbnail(); FrameBufferImage *thumbnail (); }; diff --git a/Session.cpp b/Session.cpp index 23ff798..c7a7606 100644 --- a/Session.cpp +++ b/Session.cpp @@ -87,6 +87,7 @@ void Session::update(float dt) // pre-render of all sources failedSource_ = nullptr; + bool ready = true; for( SourceList::iterator it = sources_.begin(); it != sources_.end(); ++it){ // ensure the RenderSource is rendering this session @@ -98,6 +99,8 @@ void Session::update(float dt) failedSource_ = (*it); } else { + if ( !(*it)->ready() ) + ready = false; // render the source (*it)->render(); // update the source @@ -129,6 +132,10 @@ void Session::update(float dt) // draw render view in Frame Buffer render_.draw(); + + // draw the thumbnail only after all sources are ready + if (ready) + render_.drawThumbnail(); } SourceList::iterator Session::addSource(Source *s)