author | alfadur |
Wed, 28 Nov 2018 21:10:18 +0300 | |
changeset 14339 | 7ae81969330f |
parent 14295 | 92e5682810d4 |
child 14717 | 57293f34ce59 |
permissions | -rw-r--r-- |
14148 | 1 |
#ifndef GAMEVIEW_H |
2 |
#define GAMEVIEW_H |
|
3 |
||
4 |
#include <QQuickItem> |
|
5 |
||
14295
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
6 |
#include <QPointer> |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
7 |
#include <QScopedPointer> |
14148 | 8 |
#include <QtGui/QOpenGLFunctions> |
9 |
#include <QtGui/QOpenGLShaderProgram> |
|
10 |
||
14295
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
11 |
#include "engine_instance.h" |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
12 |
|
14148 | 13 |
class GameViewRenderer : public QObject, protected QOpenGLFunctions { |
14 |
Q_OBJECT |
|
15 |
public: |
|
14295
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
16 |
GameViewRenderer(); |
14148 | 17 |
~GameViewRenderer(); |
18 |
||
14295
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
19 |
void tick(quint32 delta); |
14148 | 20 |
void setViewportSize(const QSize& size); |
14295
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
21 |
void setEngineInstance(EngineInstance* engineInstance); |
14148 | 22 |
|
23 |
public slots: |
|
24 |
void paint(); |
|
25 |
||
26 |
private: |
|
27 |
quint32 m_delta; |
|
14295
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
28 |
QPointer<EngineInstance> m_engineInstance; |
14148 | 29 |
}; |
30 |
||
31 |
class GameView : public QQuickItem { |
|
32 |
Q_OBJECT |
|
33 |
||
14295
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
34 |
Q_PROPERTY(EngineInstance* engineInstance READ engineInstance WRITE |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
35 |
setEngineInstance NOTIFY engineInstanceChanged) |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
36 |
|
14148 | 37 |
public: |
38 |
GameView(); |
|
39 |
||
40 |
Q_INVOKABLE void tick(quint32 delta); |
|
41 |
||
14295
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
42 |
EngineInstance* engineInstance() const; |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
43 |
|
14148 | 44 |
signals: |
14295
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
45 |
void engineInstanceChanged(EngineInstance* engineInstance); |
14148 | 46 |
|
47 |
public slots: |
|
48 |
void sync(); |
|
49 |
void cleanup(); |
|
14295
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
50 |
void setEngineInstance(EngineInstance* engineInstance); |
14148 | 51 |
|
52 |
private slots: |
|
53 |
void handleWindowChanged(QQuickWindow* win); |
|
54 |
||
55 |
private: |
|
56 |
quint32 m_delta; |
|
14295
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
57 |
QScopedPointer<GameViewRenderer> m_renderer; |
14148 | 58 |
bool m_windowChanged; |
59 |
qint32 m_centerX; |
|
60 |
qint32 m_centerY; |
|
14295
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14159
diff
changeset
|
61 |
QPointer<EngineInstance> m_engineInstance; |
14148 | 62 |
}; |
63 |
||
64 |
#endif // GAMEVIEW_H |