From 3518a102301973dca3190767fdc491e4362345e4 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 18 May 2020 13:41:11 +1000 Subject: [PATCH] opengl: added another bilt override for custom coordinates and mode --- .../backend/opengl/openglrenderfunctions.cpp | 22 ++++++++++++++----- .../backend/opengl/openglrenderfunctions.h | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/render/backend/opengl/openglrenderfunctions.cpp b/app/render/backend/opengl/openglrenderfunctions.cpp index 2a3b538a9..fcdc36a64 100644 --- a/app/render/backend/opengl/openglrenderfunctions.cpp +++ b/app/render/backend/opengl/openglrenderfunctions.cpp @@ -26,7 +26,7 @@ OLIVE_NAMESPACE_ENTER -const GLfloat blit_vertices[] = { +const QVector blit_vertices = { -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, @@ -36,7 +36,7 @@ const GLfloat blit_vertices[] = { 1.0f, 1.0f, 0.0f }; -const GLfloat blit_texcoords[] = { +const QVector blit_texcoords = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, @@ -46,7 +46,7 @@ const GLfloat blit_texcoords[] = { 1.0f, 1.0f }; -const GLfloat flipped_blit_texcoords[] = { +const QVector flipped_blit_texcoords = { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, @@ -141,6 +141,15 @@ void OpenGLRenderFunctions::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix } void OpenGLRenderFunctions::Blit(OpenGLShader *pipeline, bool flipped, QMatrix4x4 matrix) +{ + Blit(pipeline, + GL_TRIANGLES, + blit_vertices, + flipped ? flipped_blit_texcoords : blit_texcoords, + matrix); +} + +void OpenGLRenderFunctions::Blit(OpenGLShader *pipeline, GLenum mode, const QVector &vert, const QVector &tex, QMatrix4x4 matrix) { QOpenGLFunctions* func = QOpenGLContext::currentContext()->functions(); @@ -153,13 +162,13 @@ void OpenGLRenderFunctions::Blit(OpenGLShader *pipeline, bool flipped, QMatrix4x QOpenGLBuffer m_vbo; m_vbo.create(); m_vbo.bind(); - m_vbo.allocate(blit_vertices, 18 * sizeof(GLfloat)); + m_vbo.allocate(vert.constData(), vert.size() * sizeof(GLfloat)); m_vbo.release(); QOpenGLBuffer m_vbo2; m_vbo2.create(); m_vbo2.bind(); - m_vbo2.allocate(flipped ? flipped_blit_texcoords : blit_texcoords, 12 * sizeof(GLfloat)); + m_vbo2.allocate(tex.constData(), tex.size() * sizeof(GLfloat)); m_vbo2.release(); pipeline->bind(); @@ -179,7 +188,8 @@ void OpenGLRenderFunctions::Blit(OpenGLShader *pipeline, bool flipped, QMatrix4x func->glVertexAttribPointer(tex_location, 2, GL_FLOAT, GL_FALSE, 0, nullptr); m_vbo2.release(); - func->glDrawArrays(GL_TRIANGLES, 0, 6); + // (Size / 3) because we assume each GLfloat has an XYZ pair + func->glDrawArrays(mode, 0, blit_vertices.size() / 3); pipeline->release(); diff --git a/app/render/backend/opengl/openglrenderfunctions.h b/app/render/backend/opengl/openglrenderfunctions.h index 18fc81b47..7e31987f7 100644 --- a/app/render/backend/opengl/openglrenderfunctions.h +++ b/app/render/backend/opengl/openglrenderfunctions.h @@ -49,6 +49,8 @@ public: */ static void Blit(OpenGLShaderPtr pipeline, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4()); static void Blit(OpenGLShader* pipeline, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4()); + static void Blit(OpenGLShader* pipeline, GLenum mode, const QVector& vert, + const QVector& tex, QMatrix4x4 matrix = QMatrix4x4()); static void OCIOBlit(OpenGLShaderPtr pipeline, GLuint lut, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4()); static void OCIOBlit(OpenGLShader* pipeline, GLuint lut, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4());