From 61ecee93b866a4a4ea60b29c5c77d73a4d093b86 Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Mon, 10 Aug 2015 15:13:43 -0700 Subject: [PATCH] Fix mis-positioning of QML elements when moving from retina to non-retina display --- interface/src/Application.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index af0b77328a..44bcea5484 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1191,16 +1191,21 @@ void Application::resizeGL() { // Possible change in aspect ratio loadViewFrustum(_myCamera, _viewFrustum); + float fov = glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES); + float aspectRatio = aspect(_renderResolution); + _myCamera.setProjection(glm::perspective(fov, aspectRatio, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP)); } - _myCamera.setProjection(glm::perspective(glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES), aspect(_renderResolution), - DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP)); + auto offscreenUi = DependencyManager::get(); - auto uiSize = displayPlugin->getRecommendedUiSize(); - if (offscreenUi->size() != fromGlm(uiSize)) { + // Bit of a hack since there's no device pixel ratio change event I can find. + static qreal lastDevicePixelRatio = 0; + qreal devicePixelRatio = _window->devicePixelRatio(); + if (offscreenUi->size() != fromGlm(uiSize) || devicePixelRatio != lastDevicePixelRatio) { offscreenUi->resize(fromGlm(uiSize)); _offscreenContext->makeCurrent(); + lastDevicePixelRatio = devicePixelRatio; } }