all repos — mgba @ ad37ae3d61326865a190f4b866800474c30ebadd

mGBA Game Boy Advance Emulator

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
23protected:
24	virtual void initializeGL() override;
25	virtual void paintEvent(QPaintEvent*) override {};
26	virtual void resizeEvent(QResizeEvent*) override;
27
28private:
29	Painter* m_painter;
30	QThread* m_drawThread;
31};
32
33class Painter : public QObject {
34Q_OBJECT
35
36public:
37	Painter(Display* parent);
38
39	void setContext(GBAThread*);
40	void setBacking(const uint32_t*);
41
42public slots:
43	void draw();
44	void start();
45	void stop();
46	void resize(const QSize& size);
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