14143
|
1 |
#ifndef GAMEVIEW_H
|
|
2 |
#define GAMEVIEW_H
|
|
3 |
|
|
4 |
#include <QQuickItem>
|
|
5 |
|
|
6 |
#include <QtGui/QOpenGLFunctions>
|
|
7 |
#include <QtGui/QOpenGLShaderProgram>
|
|
8 |
|
|
9 |
class GameViewRenderer : public QObject, protected QOpenGLFunctions {
|
|
10 |
Q_OBJECT
|
|
11 |
public:
|
|
12 |
GameViewRenderer() : m_delta(0) {}
|
|
13 |
~GameViewRenderer();
|
|
14 |
|
|
15 |
void tick(quint32 delta) { m_delta = delta; }
|
|
16 |
void setViewportSize(const QSize& size);
|
|
17 |
|
|
18 |
public slots:
|
|
19 |
void paint();
|
|
20 |
|
|
21 |
private:
|
|
22 |
quint32 m_delta;
|
|
23 |
};
|
|
24 |
|
|
25 |
class GameView : public QQuickItem {
|
|
26 |
Q_OBJECT
|
|
27 |
|
|
28 |
public:
|
|
29 |
GameView();
|
|
30 |
|
|
31 |
Q_INVOKABLE void tick(quint32 delta);
|
|
32 |
|
|
33 |
signals:
|
|
34 |
void tChanged();
|
|
35 |
|
|
36 |
public slots:
|
|
37 |
void sync();
|
|
38 |
void cleanup();
|
|
39 |
|
|
40 |
private slots:
|
|
41 |
void handleWindowChanged(QQuickWindow* win);
|
|
42 |
|
|
43 |
private:
|
|
44 |
quint32 m_delta;
|
|
45 |
GameViewRenderer* m_renderer;
|
|
46 |
bool m_windowChanged;
|
|
47 |
qint32 m_centerX;
|
|
48 |
qint32 m_centerY;
|
|
49 |
};
|
|
50 |
|
|
51 |
#endif // GAMEVIEW_H
|