qmlfrontend/game_view.cpp
changeset 14298 00b56ec8b7df
parent 14290 92e5682810d4
child 14712 57293f34ce59
--- a/qmlfrontend/game_view.cpp	Mon Nov 26 14:31:36 2018 +0100
+++ b/qmlfrontend/game_view.cpp	Mon Nov 26 14:48:38 2018 +0100
@@ -45,13 +45,15 @@
 
   cleanup();
   m_engineInstance = engineInstance;
-  engineInstance->setOpenGLContext(window()->openglContext());
+
   emit engineInstanceChanged(m_engineInstance);
 }
 
 void GameView::sync() {
-  if (!m_renderer) {
+  if (!m_renderer && m_engineInstance) {
+    m_engineInstance->setOpenGLContext(window()->openglContext());
     m_renderer.reset(new GameViewRenderer());
+    m_renderer->setEngineInstance(m_engineInstance);
     connect(window(), &QQuickWindow::beforeRendering, m_renderer.data(),
             &GameViewRenderer::paint, Qt::DirectConnection);
   }
@@ -68,7 +70,7 @@
   // mousePos.y()))
   //  QCursor::setPos(mapToGlobal(QPointF(m_centerX, m_centerY)).toPoint());
 
-  m_renderer->tick(m_delta);
+  if (m_renderer) m_renderer->tick(m_delta);
 }
 
 GameViewRenderer::GameViewRenderer()