From 1caf64e315c988cd8d5196c80be96efec6c74ccc Mon Sep 17 00:00:00 2001 From: "S. Kozyr" Date: Tue, 3 Dec 2024 10:41:01 +0200 Subject: [PATCH] Fix attribute `a_position` assignment for OpenGL vertex shader Signed-off-by: S. Kozyr --- qt/qt_common/map_widget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/qt/qt_common/map_widget.cpp b/qt/qt_common/map_widget.cpp index dadde24a21..0395988cff 100644 --- a/qt/qt_common/map_widget.cpp +++ b/qt/qt_common/map_widget.cpp @@ -267,6 +267,10 @@ void MapWidget::Build() QVector4D(-1.0, -1.0, 0.0, 0.0), QVector4D(1.0, -1.0, 1.0, 0.0)}; m_vbo->allocate(static_cast(vertices), sizeof(vertices)); + QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); + f->glEnableVertexAttribArray(0); + f->glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), nullptr); + m_vbo->release(); m_program->release(); m_vao->release(); @@ -420,10 +424,7 @@ void MapWidget::paintGL() int const samplerSizeLocation = m_program->uniformLocation("u_samplerSize"); m_program->setUniformValue(samplerSizeLocation, samplerSize); - m_program->enableAttributeArray("a_position"); - m_program->setAttributeBuffer("a_position", GL_FLOAT, 0, 4, 0); - - funcs->glClearColor(0.0, 0.0, 0.0, 1.0); + funcs->glClearColor(0.5, 0.5, 0.5, 1.0); funcs->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); funcs->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);