all repos — mgba @ 9c92a29b28d1f81224ba28d5fc83a9481eccd5eb

mGBA Game Boy Advance Emulator

src/platform/qt/Display.h (view raw)

 1/* Copyright (c) 2013-2014 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef QGBA_DISPLAY
 7#define QGBA_DISPLAY
 8
 9#include <QGLWidget>
10#include <QThread>
11#include <QTimer>
12
13struct GBAThread;
14
15namespace QGBA {
16
17class Painter;
18class Display : public QGLWidget {
19Q_OBJECT
20
21public:
22	Display(QGLFormat format, QWidget* parent = nullptr);
23
24public slots:
25	void startDrawing(const uint32_t* buffer, GBAThread* context);
26	void stopDrawing();
27	void pauseDrawing();
28	void unpauseDrawing();
29	void forceDraw();
30#ifdef USE_PNG
31	void screenshot();
32#endif
33
34protected:
35	virtual void initializeGL() override;
36	virtual void paintEvent(QPaintEvent*) override {};
37	virtual void resizeEvent(QResizeEvent*) override;
38
39private:
40	Painter* m_painter;
41	QThread* m_drawThread;
42	GBAThread* m_context;
43};
44
45class Painter : public QObject {
46Q_OBJECT
47
48public:
49	Painter(Display* parent);
50
51	void setContext(GBAThread*);
52	void setBacking(const uint32_t*);
53
54public slots:
55	void forceDraw();
56	void draw();
57	void start();
58	void stop();
59	void pause();
60	void unpause();
61	void resize(const QSize& size);
62
63private:
64	QTimer* m_drawTimer;
65	GBAThread* m_context;
66	const uint32_t* m_backing;
67	GLuint m_tex;
68	QGLWidget* m_gl;
69	QSize m_size;
70};
71
72}
73
74#endif