1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Ensures changes in the framebuffer are passed onward.

This commit is contained in:
Thomas Harte 2020-06-21 17:25:21 -04:00
parent e297d4cced
commit 336dffefe0
2 changed files with 12 additions and 2 deletions

View File

@ -21,6 +21,14 @@ void ScanTargetWidget::initializeGL() {
void ScanTargetWidget::paintGL() {
glClear(GL_COLOR_BUFFER_BIT);
if(isConnected) {
// Qt reserves the right to change the framebuffer object due to window resizes or if setParent is called;
// therefore check whether it has changed.
const auto newFramebuffer = defaultFramebufferObject();
if(framebuffer != newFramebuffer) {
framebuffer = newFramebuffer;
scanTarget->set_target_framebuffer(framebuffer);
}
vsyncPredictor.begin_redraw();
scanTarget->update(width(), height());
scanTarget->draw(width(), height());
@ -41,14 +49,15 @@ void ScanTargetWidget::vsync() {
}
void ScanTargetWidget::resizeGL(int w, int h) {
glViewport(0,0,w,h);
glViewport(0, 0, w, h);
}
Outputs::Display::OpenGL::ScanTarget *ScanTargetWidget::getScanTarget() {
makeCurrent();
if(!scanTarget) {
isConnected = true;
scanTarget = std::make_unique<Outputs::Display::OpenGL::ScanTarget>(defaultFramebufferObject());
framebuffer = defaultFramebufferObject();
scanTarget = std::make_unique<Outputs::Display::OpenGL::ScanTarget>(framebuffer);
}
return scanTarget.get();
}

View File

@ -25,6 +25,7 @@ class ScanTargetWidget : public QOpenGLWidget
std::unique_ptr<Outputs::Display::OpenGL::ScanTarget> scanTarget;
Time::VSyncPredictor vsyncPredictor;
bool isConnected = false;
GLuint framebuffer = 0;
private slots:
void vsync();