author | Wuzzy <Wuzzy2@mail.ru> |
Tue, 28 May 2019 00:48:17 +0200 | |
changeset 15089 | 6f51c75994a4 |
parent 14863 | ef9630519491 |
child 16039 | a73b9770467a |
permissions | -rw-r--r-- |
14164 | 1 |
#ifndef GAMEVIEW_H |
2 |
#define GAMEVIEW_H |
|
3 |
||
4 |
#include <QQuickItem> |
|
5 |
||
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
6 |
#include <QPointer> |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
7 |
#include <QScopedPointer> |
14164 | 8 |
#include <QtGui/QOpenGLFunctions> |
9 |
#include <QtGui/QOpenGLShaderProgram> |
|
10 |
||
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
11 |
#include "engine_instance.h" |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
12 |
|
14164 | 13 |
class GameViewRenderer : public QObject, protected QOpenGLFunctions { |
14 |
Q_OBJECT |
|
15 |
public: |
|
14733 | 16 |
explicit GameViewRenderer(); |
17 |
~GameViewRenderer() override; |
|
14164 | 18 |
|
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
19 |
void tick(quint32 delta); |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
20 |
void setEngineInstance(EngineInstance* engineInstance); |
14164 | 21 |
|
22 |
public slots: |
|
23 |
void paint(); |
|
14733 | 24 |
void onViewportSizeChanged(QQuickWindow* window); |
14164 | 25 |
|
26 |
private: |
|
27 |
quint32 m_delta; |
|
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
28 |
QPointer<EngineInstance> m_engineInstance; |
14164 | 29 |
}; |
30 |
||
31 |
class GameView : public QQuickItem { |
|
32 |
Q_OBJECT |
|
33 |
||
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
34 |
Q_PROPERTY(EngineInstance* engineInstance READ engineInstance WRITE |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
35 |
setEngineInstance NOTIFY engineInstanceChanged) |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
36 |
|
14164 | 37 |
public: |
14863 | 38 |
explicit GameView(QQuickItem* parent = nullptr); |
14164 | 39 |
|
40 |
Q_INVOKABLE void tick(quint32 delta); |
|
41 |
||
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
42 |
EngineInstance* engineInstance() const; |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
43 |
|
14164 | 44 |
signals: |
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
45 |
void engineInstanceChanged(EngineInstance* engineInstance); |
14164 | 46 |
|
47 |
public slots: |
|
48 |
void sync(); |
|
49 |
void cleanup(); |
|
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
50 |
void setEngineInstance(EngineInstance* engineInstance); |
14164 | 51 |
|
52 |
private slots: |
|
53 |
void handleWindowChanged(QQuickWindow* win); |
|
54 |
||
55 |
private: |
|
56 |
quint32 m_delta; |
|
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
57 |
QScopedPointer<GameViewRenderer> m_renderer; |
14164 | 58 |
bool m_windowChanged; |
14311
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14175
diff
changeset
|
59 |
QPointer<EngineInstance> m_engineInstance; |
14733 | 60 |
QSize m_viewportSize; |
14734 | 61 |
QPoint m_centerPoint; |
14164 | 62 |
}; |
63 |
||
64 |
#endif // GAMEVIEW_H |