From 8c9c394de30ea4903457099cf30ce0d9436188fa Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 20 Nov 2018 09:37:08 +1100 Subject: [PATCH] revised superimpose effect code --- ui/viewerwidget.cpp | 12 ++++++------ ui/viewerwidget.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 0b199414a..8a652d5ca 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -216,14 +216,14 @@ void ViewerWidget::drawTitleSafeArea() { glEnd(); } -GLuint ViewerWidget::draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture) { +GLuint ViewerWidget::draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture, bool clear) { glPushMatrix(); glLoadIdentity(); glOrtho(0, 1, 0, 1, -1, 1); fbo->bind(); - glClear(GL_COLOR_BUFFER_BIT); + if (clear) glClear(GL_COLOR_BUFFER_BIT); glBindTexture(GL_TEXTURE_2D, texture); glBegin(GL_QUADS); @@ -254,13 +254,13 @@ void ViewerWidget::process_effect(Clip* c, Effect* e, double timecode, GLTexture e->startEffect(); if (e->enable_shader) { e->process_shader(timecode, coords); + composite_texture = draw_clip(c->fbo[fbo_switcher], composite_texture, true); + fbo_switcher = !fbo_switcher; } - composite_texture = draw_clip(c->fbo[fbo_switcher], composite_texture); if (e->enable_superimpose) { GLuint superimpose_texture = e->process_superimpose(timecode); - if (superimpose_texture != 0) draw_clip(c->fbo[fbo_switcher], superimpose_texture); + if (superimpose_texture != 0) composite_texture = draw_clip(c->fbo[!fbo_switcher], superimpose_texture, false); } - fbo_switcher = !fbo_switcher; } } } @@ -424,7 +424,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) c->fbo[fbo_switcher]->release(); composite_texture = c->fbo[fbo_switcher]->texture(); } else { - composite_texture = draw_clip(c->fbo[fbo_switcher], textureID); + composite_texture = draw_clip(c->fbo[fbo_switcher], textureID, true); } fbo_switcher = !fbo_switcher; diff --git a/ui/viewerwidget.h b/ui/viewerwidget.h index 15d6e41b7..f8faa1eac 100644 --- a/ui/viewerwidget.h +++ b/ui/viewerwidget.h @@ -43,7 +43,7 @@ private: bool dragging; void seek_from_click(int x); GLuint compose_sequence(QVector &nests, bool render_audio); - GLuint draw_clip(QOpenGLFramebufferObject *clip, GLuint texture); + GLuint draw_clip(QOpenGLFramebufferObject *clip, GLuint texture, bool clear); void process_effect(Clip* c, Effect* e, double timecode, GLTextureCoords& coords, GLuint& composite_texture, bool& fbo_switcher); private slots: void retry();