2020-06-04 03:39:16 +00:00
|
|
|
#include "scantargetwidget.h"
|
|
|
|
|
2020-06-05 02:39:32 +00:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QOpenGLContext>
|
2020-06-05 02:58:02 +00:00
|
|
|
#include <QTimer>
|
2020-06-05 02:39:32 +00:00
|
|
|
|
2020-06-04 03:39:16 +00:00
|
|
|
ScanTargetWidget::ScanTargetWidget(QWidget *parent) : QOpenGLWidget(parent) {}
|
|
|
|
ScanTargetWidget::~ScanTargetWidget() {}
|
|
|
|
|
|
|
|
void ScanTargetWidget::initializeGL() {
|
|
|
|
glClearColor(0.5, 0.5, 1.0, 1.0);
|
2020-06-05 02:39:32 +00:00
|
|
|
|
2020-06-06 02:11:17 +00:00
|
|
|
// qDebug() << "share context: " << bool(context()->shareGroup());
|
2020-06-04 03:39:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScanTargetWidget::paintGL() {
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
2020-06-05 02:39:32 +00:00
|
|
|
if(scanTarget) {
|
|
|
|
scanTarget->update(width(), height());
|
|
|
|
scanTarget->draw(width(), height());
|
2020-06-05 02:58:02 +00:00
|
|
|
QTimer::singleShot(500, this, SLOT(update())); // TODO: obviously this is nonsense.
|
2020-06-05 02:39:32 +00:00
|
|
|
}
|
2020-06-04 03:39:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScanTargetWidget::resizeGL(int w, int h) {
|
|
|
|
glViewport(0,0,w,h);
|
|
|
|
}
|
|
|
|
|
|
|
|
Outputs::Display::OpenGL::ScanTarget *ScanTargetWidget::getScanTarget() {
|
2020-06-05 02:39:32 +00:00
|
|
|
makeCurrent();
|
|
|
|
if(!scanTarget) {
|
|
|
|
scanTarget = std::make_unique<Outputs::Display::OpenGL::ScanTarget>(defaultFramebufferObject());
|
2020-06-05 02:58:02 +00:00
|
|
|
QTimer::singleShot(500, this, SLOT(update())); // TODO: obviously this is nonsense.
|
2020-06-05 02:39:32 +00:00
|
|
|
}
|
2020-06-04 03:39:16 +00:00
|
|
|
return scanTarget.get();
|
|
|
|
}
|