1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-24 12:30:17 +00:00

Decouples scan target drawing and lifetime.

This commit is contained in:
Thomas Harte 2020-06-21 17:20:44 -04:00
parent b052ca5ca2
commit e297d4cced
2 changed files with 3 additions and 1 deletions

View File

@ -20,7 +20,7 @@ void ScanTargetWidget::initializeGL() {
void ScanTargetWidget::paintGL() {
glClear(GL_COLOR_BUFFER_BIT);
if(scanTarget) {
if(isConnected) {
vsyncPredictor.begin_redraw();
scanTarget->update(width(), height());
scanTarget->draw(width(), height());
@ -47,6 +47,7 @@ void ScanTargetWidget::resizeGL(int w, int h) {
Outputs::Display::OpenGL::ScanTarget *ScanTargetWidget::getScanTarget() {
makeCurrent();
if(!scanTarget) {
isConnected = true;
scanTarget = std::make_unique<Outputs::Display::OpenGL::ScanTarget>(defaultFramebufferObject());
}
return scanTarget.get();

View File

@ -24,6 +24,7 @@ class ScanTargetWidget : public QOpenGLWidget
// can't be done at creation time.
std::unique_ptr<Outputs::Display::OpenGL::ScanTarget> scanTarget;
Time::VSyncPredictor vsyncPredictor;
bool isConnected = false;
private slots:
void vsync();