diff --git a/OSBindings/Qt/scantargetwidget.cpp b/OSBindings/Qt/scantargetwidget.cpp index 93d100e13..4387de8fd 100644 --- a/OSBindings/Qt/scantargetwidget.cpp +++ b/OSBindings/Qt/scantargetwidget.cpp @@ -11,6 +11,7 @@ #include #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(); diff --git a/Outputs/OpenGL/Primitives/Shader.cpp b/Outputs/OpenGL/Primitives/Shader.cpp index 7d34d1ed8..af03014a5 100644 --- a/Outputs/OpenGL/Primitives/Shader.cpp +++ b/Outputs/OpenGL/Primitives/Shader.cpp @@ -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; } @@ -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); }