diff --git a/app/render/backend/opengl/openglrenderfunctions.cpp b/app/render/backend/opengl/openglrenderfunctions.cpp index 2e6458b10..2a3b538a9 100644 --- a/app/render/backend/opengl/openglrenderfunctions.cpp +++ b/app/render/backend/opengl/openglrenderfunctions.cpp @@ -37,23 +37,23 @@ const GLfloat blit_vertices[] = { }; const GLfloat blit_texcoords[] = { - 0.0, 0.0, - 1.0, 0.0, - 1.0, 1.0, + 0.0f, 0.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, - 0.0, 0.0, - 0.0, 1.0, - 1.0, 1.0 + 0.0f, 0.0f, + 0.0f, 1.0f, + 1.0f, 1.0f }; const GLfloat flipped_blit_texcoords[] = { - 0.0, 1.0, - 1.0, 1.0, - 1.0, 0.0, + 0.0f, 1.0f, + 1.0f, 1.0f, + 1.0f, 0.0f, - 0.0, 1.0, - 0.0, 0.0, - 1.0, 0.0 + 0.0f, 1.0f, + 0.0f, 0.0f, + 1.0f, 0.0f }; /** @@ -65,7 +65,8 @@ const GLfloat flipped_blit_texcoords[] = { * * Currently active QOpenGLFunctions object (use context()->functions() if unsure). */ -void OpenGLRenderFunctions::PrepareToDraw(QOpenGLFunctions* f) { +void OpenGLRenderFunctions::PrepareToDraw(QOpenGLFunctions* f) +{ f->glGenerateMipmap(GL_TEXTURE_2D); f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -141,7 +142,6 @@ void OpenGLRenderFunctions::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix void OpenGLRenderFunctions::Blit(OpenGLShader *pipeline, bool flipped, QMatrix4x4 matrix) { - // FIXME: is currentContext() reliable here? QOpenGLFunctions* func = QOpenGLContext::currentContext()->functions(); PrepareToDraw(func); @@ -153,13 +153,13 @@ void OpenGLRenderFunctions::Blit(OpenGLShader *pipeline, bool flipped, QMatrix4x QOpenGLBuffer m_vbo; m_vbo.create(); m_vbo.bind(); - m_vbo.allocate(blit_vertices, 18 * static_cast(sizeof(GLfloat))); + m_vbo.allocate(blit_vertices, 18 * sizeof(GLfloat)); m_vbo.release(); QOpenGLBuffer m_vbo2; m_vbo2.create(); m_vbo2.bind(); - m_vbo2.allocate(flipped ? flipped_blit_texcoords : blit_texcoords, 12 * static_cast(sizeof(GLfloat))); + m_vbo2.allocate(flipped ? flipped_blit_texcoords : blit_texcoords, 12 * sizeof(GLfloat)); m_vbo2.release(); pipeline->bind(); @@ -167,13 +167,13 @@ void OpenGLRenderFunctions::Blit(OpenGLShader *pipeline, bool flipped, QMatrix4x pipeline->setUniformValue("ove_mvpmat", matrix); pipeline->setUniformValue("ove_maintex", 0); - GLuint vertex_location = static_cast(pipeline->attributeLocation("a_position")); + int vertex_location = pipeline->attributeLocation("a_position"); m_vbo.bind(); func->glEnableVertexAttribArray(vertex_location); func->glVertexAttribPointer(vertex_location, 3, GL_FLOAT, GL_FALSE, 0, nullptr); m_vbo.release(); - GLuint tex_location = static_cast(pipeline->attributeLocation("a_texcoord")); + int tex_location = pipeline->attributeLocation("a_texcoord"); m_vbo2.bind(); func->glEnableVertexAttribArray(tex_location); func->glVertexAttribPointer(tex_location, 2, GL_FLOAT, GL_FALSE, 0, nullptr); diff --git a/app/render/backend/opengl/openglshader.cpp b/app/render/backend/opengl/openglshader.cpp index b5aa8dc8b..21ff57752 100644 --- a/app/render/backend/opengl/openglshader.cpp +++ b/app/render/backend/opengl/openglshader.cpp @@ -61,8 +61,8 @@ OpenGLShaderPtr OpenGLShader::CreateOCIO(QOpenGLContext* ctx, shaderDesc.setLut3DEdgeLen(OCIO_LUT3D_EDGE_SIZE); // Compute LUT - GLfloat* ocio_lut_data = new GLfloat[OCIO_NUM_3D_ENTRIES]; - processor->getGpuLut3D(ocio_lut_data, shaderDesc); + std::vector ocio_lut_data(OCIO_NUM_3D_ENTRIES); + processor->getGpuLut3D(&ocio_lut_data[0], shaderDesc); // Create LUT texture xf->glGenTextures(1, &lut_texture); @@ -81,10 +81,7 @@ OpenGLShaderPtr OpenGLShader::CreateOCIO(QOpenGLContext* ctx, // Allocate storage for texture xf->glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB16F, OCIO_LUT3D_EDGE_SIZE, OCIO_LUT3D_EDGE_SIZE, OCIO_LUT3D_EDGE_SIZE, - 0, GL_RGB, GL_FLOAT, ocio_lut_data); - - // Delete local copy - delete [] ocio_lut_data; + 0, GL_RGB, GL_FLOAT, &ocio_lut_data[0]); // Create OCIO shader code QString shader_text; diff --git a/app/widget/viewer/viewerglwidget.cpp b/app/widget/viewer/viewerglwidget.cpp index a4cbe935f..5edd99ec1 100644 --- a/app/widget/viewer/viewerglwidget.cpp +++ b/app/widget/viewer/viewerglwidget.cpp @@ -266,7 +266,7 @@ void ViewerGLWidget::paintGL() framebuffer_.Attach(&managed_texture_); framebuffer_.Bind(); - context()->functions()->glViewport(0, 0, managed_texture_.width(), managed_texture_.height()); + f->glViewport(0, 0, managed_texture_.width(), managed_texture_.height()); } @@ -289,7 +289,7 @@ void ViewerGLWidget::paintGL() // Bind retrieved texture managed_texture_.Bind(); - context()->functions()->glViewport(0, 0, width(), height()); + f->glViewport(0, 0, width(), height()); OpenGLRenderFunctions::Blit(managed_copy_pipeline_);