all repos — mgba @ 8e4a3439c05395f0c274db4d9089f75867cd71f4

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	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	GBAThread* m_context;
33};
34
35class Painter : public QObject {
36Q_OBJECT
37
38public:
39	Painter(Display* parent);
40
41	void setContext(GBAThread*);
42	void setBacking(const uint32_t*);
43
44public slots:
45	void forceDraw();
46	void draw();
47	void start();
48	void stop();
49	void resize(const QSize& size);
50
51private:
52	QTimer* m_drawTimer;
53	GBAThread* m_context;
54	const uint32_t* m_backing;
55	GLuint m_tex;
56	QGLWidget* m_gl;
57	QSize m_size;
58};
59
60}
61
62#endif