all repos — mgba @ aed170b6700314d0913038ea17f869b013a5d301

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