qmlfrontend/game_view.cpp
changeset 14713 cc6ab1e3f7d5
parent 14712 57293f34ce59
child 14842 ef9630519491
--- a/qmlfrontend/game_view.cpp	Fri Mar 22 21:06:12 2019 +0100
+++ b/qmlfrontend/game_view.cpp	Fri Mar 22 21:29:10 2019 +0100
@@ -65,12 +65,14 @@
       m_engineInstance->setOpenGLContext(window()->openglContext());
 
     m_viewportSize = window()->size();
+    m_centerPoint = QPoint(m_viewportSize.width(), m_viewportSize.height()) / 2;
   }
 
-  // QPoint mousePos = mapFromGlobal(QCursor::pos()).toPoint();
-  // if (flibUpdateMousePosition(m_centerX, m_centerY, mousePos.x(),
-  // mousePos.y()))
-  //  QCursor::setPos(mapToGlobal(QPointF(m_centerX, m_centerY)).toPoint());
+  if (m_engineInstance) {
+    QPoint mousePos = mapFromGlobal(QCursor::pos()).toPoint();
+    m_engineInstance->moveCamera(mousePos - m_centerPoint);
+    QCursor::setPos(mapToGlobal(m_centerPoint).toPoint());
+  }
 
   if (m_renderer) m_renderer->tick(m_delta);
 }