all repos — mgba @ 1ef3f4256faabc8a7caa029b1c21ea52bba4879d

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(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	void setGLContext(QGLWidget*);
42
43public slots:
44	void draw();
45	void start();
46	void stop();
47	void resize(const QSize& size);
48
49private:
50	QTimer* m_drawTimer;
51	GBAThread* m_context;
52	const uint32_t* m_backing;
53	GLuint m_tex;
54	QGLWidget* m_gl;
55	QSize m_size;
56};
57
58}
59
60#endif