--- a/qmlfrontend/game_view.h Fri Apr 05 13:10:55 2024 +0100
+++ b/qmlfrontend/game_view.h Fri Apr 19 17:44:55 2024 +0200
@@ -1,34 +1,13 @@
#ifndef GAMEVIEW_H
#define GAMEVIEW_H
-#include <QQuickItem>
-
#include <QPointer>
+#include <QQuickFramebufferObject>
#include <QScopedPointer>
-#include <QtGui/QOpenGLFunctions>
-#include <QtGui/QOpenGLShaderProgram>
#include "engine_instance.h"
-class GameViewRenderer : public QObject, protected QOpenGLFunctions {
- Q_OBJECT
- public:
- explicit GameViewRenderer();
- ~GameViewRenderer() override;
-
- void tick(quint32 delta);
- void setEngineInstance(EngineInstance* engineInstance);
-
- public slots:
- void paint();
- void onViewportSizeChanged(QQuickWindow* window);
-
- private:
- quint32 m_delta;
- QPointer<EngineInstance> m_engineInstance;
-};
-
-class GameView : public QQuickItem {
+class GameView : public QQuickFramebufferObject {
Q_OBJECT
Q_PROPERTY(EngineInstance* engineInstance READ engineInstance WRITE
@@ -41,21 +20,16 @@
EngineInstance* engineInstance() const;
- signals:
+ Renderer* createRenderer() const override;
+
+ Q_SIGNALS:
void engineInstanceChanged(EngineInstance* engineInstance);
- public slots:
- void sync();
- void cleanup();
+ public Q_SLOTS:
void setEngineInstance(EngineInstance* engineInstance);
- private slots:
- void handleWindowChanged(QQuickWindow* win);
-
private:
quint32 m_delta;
- QScopedPointer<GameViewRenderer> m_renderer;
- bool m_windowChanged;
QPointer<EngineInstance> m_engineInstance;
QSize m_viewportSize;
QPoint m_centerPoint;