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

51 lines
1.2 KiB
C++

#ifndef SCANTARGETWIDGET_H
#define SCANTARGETWIDGET_H
#include <QOpenGLWidget>
#include "../../Outputs/OpenGL/ScanTarget.hpp"
#include "../../Machines/ScanProducer.hpp"
#include "../../ClockReceiver/VSyncPredictor.hpp"
class ScanTargetWidget : public QOpenGLWidget
{
public:
ScanTargetWidget(QWidget *parent = nullptr);
~ScanTargetWidget();
// Sets the current scan producer; this scan producer will be
// handed a suitable scan target as soon as one exists.
void setScanProducer(MachineTypes::ScanProducer *);
void stop();
protected:
void initializeGL() override;
void resizeGL(int w, int h) override;
void paintGL() override;
private:
// This should be created only once there's an OpenGL context. So it
// can't be done at creation time.
std::unique_ptr<Outputs::Display::OpenGL::ScanTarget> scanTarget;
Time::VSyncPredictor vsyncPredictor;
bool isConnected = false;
GLuint framebuffer = 0;
MachineTypes::ScanProducer *producer = nullptr;
Time::Nanos requested_redraw_time_ = 0;
void setDefaultClearColour();
int width = 0, height = 0;
int scaledWidth = 0, scaledHeight = 0;
float outputScale = 1.0f;
void resize();
private slots:
void vsync();
};
#endif // SCANTARGETWIDGET_H