fixed bug that caused flickering textures

The ViewerGLWidget would receive raw GLuint textures while most of Olive uses
an OpenGLTexture C++ wrapper. Unfortunately this would lead to the C++ wrapper
getting destroyed since its instance wasn't kept in the ViewerGLWidget. This
meant by the time the ViewerGLWidget would re-draw, the texture would have
already been destroyed leading to some black frames. This is now fixed.
This commit is contained in:
itsmattkc
2019-12-27 05:11:42 +11:00
parent 549427353d
commit a4b3dc2ab4
3 changed files with 13 additions and 19 deletions
+1 -5
View File
@@ -205,11 +205,7 @@ VideoRenderBackend *ViewerWidget::video_renderer() const
void ViewerWidget::SetTexture(OpenGLTexturePtr tex)
{
if (tex == nullptr) {
gl_widget_->SetTexture(0);
} else {
gl_widget_->SetTexture(tex->texture());
}
gl_widget_->SetTexture(tex);
}
void ViewerWidget::UpdateTimeInternal(int64_t i)
+8 -11
View File
@@ -96,7 +96,7 @@ void ViewerGLWidget::SetOCIOLook(const QString &look)
update();
}
void ViewerGLWidget::SetTexture(GLuint tex)
void ViewerGLWidget::SetTexture(OpenGLTexturePtr tex)
{
// Update the texture
texture_ = tex;
@@ -124,7 +124,7 @@ void ViewerGLWidget::initializeGL()
void ViewerGLWidget::paintGL()
{
// We only draw if we have a pipeline
if (!pipeline_) {
if (!pipeline_ || !texture_) {
return;
}
@@ -135,17 +135,14 @@ void ViewerGLWidget::paintGL()
f->glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
f->glClear(GL_COLOR_BUFFER_BIT);
// Check if we have a texture to draw
if (texture_ > 0) {
// Bind retrieved texture
f->glBindTexture(GL_TEXTURE_2D, texture_);
// Bind retrieved texture
f->glBindTexture(GL_TEXTURE_2D, texture_->texture());
// Blit using the pipeline retrieved in initializeGL()
OpenGLRenderFunctions::OCIOBlit(pipeline_, ocio_lut_, true, matrix_);
// Blit using the pipeline retrieved in initializeGL()
OpenGLRenderFunctions::OCIOBlit(pipeline_, ocio_lut_, true, matrix_);
// Release retrieved texture
f->glBindTexture(GL_TEXTURE_2D, 0);
}
// Release retrieved texture
f->glBindTexture(GL_TEXTURE_2D, 0);
}
void ViewerGLWidget::RefreshColorPipeline()
+4 -3
View File
@@ -23,8 +23,9 @@
#include <QOpenGLWidget>
#include "render/colormanager.h"
#include "render/backend/opengl/openglshader.h"
#include "render/backend/opengl/opengltexture.h"
#include "render/colormanager.h"
/**
* @brief The inner display/rendering widget of a Viewer class.
@@ -109,7 +110,7 @@ public slots:
*
* @param tex
*/
void SetTexture(GLuint tex);
void SetTexture(OpenGLTexturePtr tex);
void SetOCIOParameters(const QString& display, const QString& view, const QString& look);
@@ -178,7 +179,7 @@ private:
/**
* @brief Internal reference to the OpenGL texture to draw. Set in SetTexture() and used in paintGL().
*/
GLuint texture_;
OpenGLTexturePtr texture_;
/**
* @brief Internal shader object to use as the pipeline shader