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:
parent
e297d4cced
commit
336dffefe0
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user