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(QWidget* parent = 0);
18
19public slots:
20 void startDrawing(const uint32_t* buffer, GBAThread* context);
21 void stopDrawing();
22
23protected:
24 virtual void paintEvent(QPaintEvent*) {};
25 virtual void resizeEvent(QResizeEvent*);
26
27private:
28 Painter* m_painter;
29 QThread* m_drawThread;
30};
31
32class Painter : public QObject {
33Q_OBJECT
34
35public:
36 Painter(Display* parent);
37
38 void setContext(GBAThread*);
39 void setBacking(const uint32_t*);
40 void setGLContext(QGLWidget*);
41 void resize(const QSize& size);
42
43public slots:
44 void draw();
45 void start();
46 void stop();
47
48private:
49 QTimer* m_drawTimer;
50 GBAThread* m_context;
51 const uint32_t* m_backing;
52 GLuint m_tex;
53 QGLWidget* m_gl;
54 QSize m_size;
55};
56
57}
58
59#endif