src/platform/qt/Display.h (view raw)
1#ifndef QGBA_DISPLAY
2#define QGBA_DISPLAY
3
4#include <QGLWidget>
5#include <QThread>
6#include <QTimer>
7
8struct GBAThread;
9
10namespace QGBA {
11
12class Painter;
13class Display : public QGLWidget {
14Q_OBJECT
15
16public:
17 Display(QGLFormat format, QWidget* parent = nullptr);
18
19public slots:
20 void startDrawing(const uint32_t* buffer, GBAThread* context);
21 void stopDrawing();
22 void forceDraw();
23
24protected:
25 virtual void initializeGL() override;
26 virtual void paintEvent(QPaintEvent*) override {};
27 virtual void resizeEvent(QResizeEvent*) override;
28
29private:
30 Painter* m_painter;
31 QThread* m_drawThread;
32};
33
34class Painter : public QObject {
35Q_OBJECT
36
37public:
38 Painter(Display* parent);
39
40 void setContext(GBAThread*);
41 void setBacking(const uint32_t*);
42
43public slots:
44 void forceDraw();
45 void draw();
46 void start();
47 void stop();
48 void resize(const QSize& size);
49
50private:
51 QTimer* m_drawTimer;
52 GBAThread* m_context;
53 const uint32_t* m_backing;
54 GLuint m_tex;
55 QGLWidget* m_gl;
56 QSize m_size;
57};
58
59}
60
61#endif