1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-01-22 08:26:48 +00:00

Give Qt full ownership of its workaround.

This commit is contained in:
Thomas Harte
2025-12-01 20:51:15 +00:00
parent e4fd4519c4
commit cf777816ce
2 changed files with 5 additions and 12 deletions

View File

@@ -11,6 +11,7 @@
#include <QTimer>
#include "../../ClockReceiver/TimeTypes.hpp"
#include "../../Outputs/OpenGL/Primitives/Shader.hpp"
ScanTargetWidget::ScanTargetWidget(QWidget *parent) : QOpenGLWidget(parent) {}
ScanTargetWidget::~ScanTargetWidget() {}
@@ -50,6 +51,10 @@ void ScanTargetWidget::paintGL() {
// a scan target in ::initializeGL did not work (and no other arrangement really works
// with regard to starting up).
if(isConnected || producer) {
// Qt-specific workaround. I can but speculate as to why, but the bound program does
// not necessarily survive between calls into paintGL.
Outputs::Display::OpenGL::Shader::unbind();
if(producer) {
isConnected = true;
framebuffer = defaultFramebufferObject();

View File

@@ -14,9 +14,7 @@
using namespace Outputs::Display::OpenGL;
namespace {
#ifndef TARGET_QT
thread_local const Shader *bound_shader = nullptr;
#endif
using Logger = Log::Logger<Log::Source::OpenGL>;
}
@@ -108,30 +106,20 @@ void Shader::init(const std::string &vertex_shader, const std::string &fragment_
}
Shader::~Shader() {
#ifndef TARGET_QT
if(bound_shader == this) Shader::unbind();
#endif
glDeleteProgram(shader_program_);
}
void Shader::bind() const {
#ifndef TARGET_QT
// Qt workaround: it's doing something to interfere with the currently-bound program.
// So assume that the driver has a check similar to the below.
if(bound_shader != this) {
test_gl(glUseProgram, shader_program_);
bound_shader = this;
}
#else
test_gl(glUseProgram, shader_program_);
#endif
flush_functions();
}
void Shader::unbind() {
#ifndef TARGET_QT
bound_shader = nullptr;
#endif
test_gl(glUseProgram, 0);
}