qmlfrontend/game_view.cpp
changeset 14712 57293f34ce59
parent 14298 00b56ec8b7df
child 14713 cc6ab1e3f7d5
--- a/qmlfrontend/game_view.cpp	Fri Mar 22 22:26:41 2019 +0300
+++ b/qmlfrontend/game_view.cpp	Fri Mar 22 21:06:12 2019 +0100
@@ -58,11 +58,13 @@
             &GameViewRenderer::paint, Qt::DirectConnection);
   }
 
-  if (m_windowChanged) {
-    QSize windowSize = window()->size();
-    m_renderer->setViewportSize(windowSize * window()->devicePixelRatio());
-    m_centerX = windowSize.width() / 2;
-    m_centerY = windowSize.height() / 2;
+  if (m_windowChanged || (m_viewportSize != window()->size())) {
+    m_windowChanged = false;
+
+    if (m_engineInstance)
+      m_engineInstance->setOpenGLContext(window()->openglContext());
+
+    m_viewportSize = window()->size();
   }
 
   // QPoint mousePos = mapFromGlobal(QCursor::pos()).toPoint();
@@ -80,10 +82,6 @@
 
 void GameViewRenderer::tick(quint32 delta) { m_delta = delta; }
 
-void GameViewRenderer::setViewportSize(const QSize& size) {
-  // flibResizeWindow(size.width(), size.height());
-}
-
 void GameViewRenderer::setEngineInstance(EngineInstance* engineInstance) {
   m_engineInstance = engineInstance;
 }
@@ -98,3 +96,8 @@
 
   // m_window->resetOpenGLState();
 }
+
+void GameViewRenderer::onViewportSizeChanged(QQuickWindow* window) {
+  if (m_engineInstance)
+    m_engineInstance->setOpenGLContext(window->openglContext());
+}