qmlfrontend/game_view.cpp
changeset 16015 0e90bdfc2642
parent 16010 a73b9770467a
child 16017 e8afb1bf2779
--- a/qmlfrontend/game_view.cpp	Thu May 16 14:11:16 2024 +0200
+++ b/qmlfrontend/game_view.cpp	Sun May 19 15:55:26 2024 +0200
@@ -23,7 +23,8 @@
 
   QPointer<GameView> m_gameView;
   QPointer<QQuickWindow> m_window;
-  bool m_inited{false};
+  bool m_dirty{true};
+  QSizeF m_gameViewSize;
 };
 
 void GameViewRenderer::render() {
@@ -33,8 +34,8 @@
     return;
   }
 
-  if (!m_inited) {
-    m_inited = true;
+  if (m_dirty) {
+    m_dirty = false;
     engine->setOpenGLContext(QOpenGLContext::currentContext());
   }
 
@@ -57,6 +58,12 @@
     m_gameView = qobject_cast<GameView*>(fbo);
     m_window = fbo->window();
   }
+
+  if (const auto currentSize = m_gameView->size();
+      currentSize != m_gameViewSize) {
+    m_gameViewSize = currentSize;
+    m_dirty = true;
+  }
 }
 
 GameView::GameView(QQuickItem* parent)