mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-29 12:50:28 +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() {
|
void ScanTargetWidget::paintGL() {
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
if(isConnected) {
|
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();
|
vsyncPredictor.begin_redraw();
|
||||||
scanTarget->update(width(), height());
|
scanTarget->update(width(), height());
|
||||||
scanTarget->draw(width(), height());
|
scanTarget->draw(width(), height());
|
||||||
@ -41,14 +49,15 @@ void ScanTargetWidget::vsync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScanTargetWidget::resizeGL(int w, int h) {
|
void ScanTargetWidget::resizeGL(int w, int h) {
|
||||||
glViewport(0,0,w,h);
|
glViewport(0, 0, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
Outputs::Display::OpenGL::ScanTarget *ScanTargetWidget::getScanTarget() {
|
Outputs::Display::OpenGL::ScanTarget *ScanTargetWidget::getScanTarget() {
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
if(!scanTarget) {
|
if(!scanTarget) {
|
||||||
isConnected = true;
|
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();
|
return scanTarget.get();
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ class ScanTargetWidget : public QOpenGLWidget
|
|||||||
std::unique_ptr<Outputs::Display::OpenGL::ScanTarget> scanTarget;
|
std::unique_ptr<Outputs::Display::OpenGL::ScanTarget> scanTarget;
|
||||||
Time::VSyncPredictor vsyncPredictor;
|
Time::VSyncPredictor vsyncPredictor;
|
||||||
bool isConnected = false;
|
bool isConnected = false;
|
||||||
|
GLuint framebuffer = 0;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void vsync();
|
void vsync();
|
||||||
|
Loading…
Reference in New Issue
Block a user