--- 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());
+}