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 pauseDrawing();
23 void unpauseDrawing();
24 void forceDraw();
25#ifdef USE_PNG
26 void screenshot();
27#endif
28
29protected:
30 virtual void initializeGL() override;
31 virtual void paintEvent(QPaintEvent*) override {};
32 virtual void resizeEvent(QResizeEvent*) override;
33
34private:
35 Painter* m_painter;
36 QThread* m_drawThread;
37 GBAThread* m_context;
38};
39
40class Painter : public QObject {
41Q_OBJECT
42
43public:
44 Painter(Display* parent);
45
46 void setContext(GBAThread*);
47 void setBacking(const uint32_t*);
48
49public slots:
50 void forceDraw();
51 void draw();
52 void start();
53 void stop();
54 void pause();
55 void unpause();
56 void resize(const QSize& size);
57
58private:
59 QTimer* m_drawTimer;
60 GBAThread* m_context;
61 const uint32_t* m_backing;
62 GLuint m_tex;
63 QGLWidget* m_gl;
64 QSize m_size;
65};
66
67}
68
69#endif