Fixing scale resolution issues
Showing the changes to interface/src/Application.cpp (1 of 13 files). Show all
Unified · Split
| @@ -812,8 +812,7 @@ void Application::initializeUi() { · 811 unmodified lines | |||
| 812 | if (devicePixelRatio != oldDevicePixelRatio) { | 812 | if (devicePixelRatio != oldDevicePixelRatio) { |
| 813 | oldDevicePixelRatio = devicePixelRatio; | 813 | oldDevicePixelRatio = devicePixelRatio; |
| 814 | qDebug() << "Device pixel ratio changed, triggering GL resize"; | 814 | qDebug() << "Device pixel ratio changed, triggering GL resize"; |
| 815 | resizeGL(_glWidget->width(), | 815 | resizeGL(); |
| 816 | _glWidget->height()); | ||
| 817 | } | 816 | } |
| 818 | }); | 817 | }); |
| 819 | } | 818 | } |
| @@ -830,15 +829,7 @@ void Application::paintGL() { · 10 unmodified lines | |||
| 830 | PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings)); | 829 | PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings)); |
| 831 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 830 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 832 | PerformanceWarning warn(showWarnings, "Application::paintGL()"); | 831 | PerformanceWarning warn(showWarnings, "Application::paintGL()"); |
| 833 | 832 | resizeGL(); | |
| 834 | // Set the desired FBO texture size. If it hasn't changed, this does nothing. | ||
| 835 | // Otherwise, it must rebuild the FBOs | ||
| 836 | if (OculusManager::isConnected()) { | ||
| 837 | DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize()); | ||
| 838 | } else { | ||
| 839 | QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale(); | ||
| 840 | DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize); | ||
| 841 | } | ||
| 842 | 833 | ||
| 843 | glEnable(GL_LINE_SMOOTH); | 834 | glEnable(GL_LINE_SMOOTH); |
| 844 | 835 | ||
| @@ -915,7 +906,14 @@ void Application::paintGL() { · 70 unmodified lines | |||
| 915 | renderRearViewMirror(_mirrorViewRect); | 906 | renderRearViewMirror(_mirrorViewRect); |
| 916 | } | 907 | } |
| 917 | 908 | ||
| 918 | DependencyManager::get<GlowEffect>()->render(); | 909 | auto finalFbo = DependencyManager::get<GlowEffect>()->render(); |
| 910 | |||
| 911 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); | ||
| 912 | glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo)); | ||
| 913 | glBlitFramebuffer(0, 0, _renderResolution.x, _renderResolution.y, | ||
| 914 | 0, 0, _glWidget->getDeviceSize().width(), _glWidget->getDeviceSize().height(), | ||
| 915 | GL_COLOR_BUFFER_BIT, GL_NEAREST); | ||
| 916 | |||
| 919 | 917 | ||
| 920 | { | 918 | { |
| 921 | PerformanceTimer perfTimer("renderOverlay"); | 919 | PerformanceTimer perfTimer("renderOverlay"); |
| @@ -960,33 +958,47 @@ void Application::showEditEntitiesHelp() { · 38 unmodified lines | |||
| 960 | InfoView::show(INFO_EDIT_ENTITIES_PATH); | 958 | InfoView::show(INFO_EDIT_ENTITIES_PATH); |
| 961 | } | 959 | } |
| 962 | 960 | ||
| 963 | void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) { | 961 | void Application::resetCamerasOnResizeGL(Camera& camera, const glm::uvec2& size) { |
| 964 | if (OculusManager::isConnected()) { | 962 | if (OculusManager::isConnected()) { |
| 965 | OculusManager::configureCamera(camera, width, height); | 963 | OculusManager::configureCamera(camera, size.x, size.y); |
| 966 | } else if (TV3DManager::isConnected()) { | 964 | } else if (TV3DManager::isConnected()) { |
| 967 | TV3DManager::configureCamera(camera, width, height); | 965 | TV3DManager::configureCamera(camera, size.x, size.y); |
| 968 | } else { | 966 | } else { |
| 969 | camera.setAspectRatio((float)width / height); | 967 | camera.setAspectRatio((float)size.x / size.y); |
| 970 | camera.setFieldOfView(_fieldOfView.get()); | 968 | camera.setFieldOfView(_fieldOfView.get()); |
| 971 | } | 969 | } |
| 972 | } | 970 | } |
| 973 | 971 | ||
| 974 | void Application::resizeGL(int width, int height) { | 972 | void Application::resizeGL() { |
| 975 | DependencyManager::get<TextureCache>()->setFrameBufferSize(QSize(width, height)); | 973 | // Set the desired FBO texture size. If it hasn't changed, this does nothing. |
| 976 | resetCamerasOnResizeGL(_myCamera, width, height); | 974 | // Otherwise, it must rebuild the FBOs |
| 975 | QSize renderSize; | ||
| 976 | if (OculusManager::isConnected()) { | ||
| 977 | renderSize = OculusManager::getRenderTargetSize(); | ||
| 978 | } else { | ||
| 979 | renderSize = _glWidget->getDeviceSize() * getRenderResolutionScale(); | ||
| 980 | } | ||
| 981 | if (_renderResolution == toGlm(renderSize)) { | ||
| 982 | return; | ||
| 983 | } | ||
| 984 | |||
| 985 | _renderResolution = toGlm(renderSize); | ||
| 986 | DependencyManager::get<TextureCache>()->setFrameBufferSize(renderSize); | ||
| 987 | resetCamerasOnResizeGL(_myCamera, _renderResolution); | ||
| 977 | 988 | ||
| 978 | glViewport(0, 0, width, height); // shouldn't this account for the menu??? | 989 | glViewport(0, 0, _renderResolution.x, _renderResolution.y); // shouldn't this account for the menu??? |
| 979 | 990 | ||
| 980 | updateProjectionMatrix(); | 991 | updateProjectionMatrix(); |
| 981 | glLoadIdentity(); | 992 | glLoadIdentity(); |
| 982 | 993 | ||
| 983 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 994 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 984 | offscreenUi->resize(_glWidget->size()); | 995 | offscreenUi->resize(_glWidget->size()); |
| 996 | _glWidget->makeCurrent(); | ||
| 985 | 997 | ||
| 986 | // update Stats width | 998 | // update Stats width |
| 987 | // let's set horizontal offset to give stats some margin to mirror | 999 | // let's set horizontal offset to give stats some margin to mirror |
| 988 | int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; | 1000 | int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; |
| 989 | Stats::getInstance()->resetWidth(width, horizontalOffset); | 1001 | Stats::getInstance()->resetWidth(_renderResolution.x, horizontalOffset); |
| 990 | } | 1002 | } |
| 991 | 1003 | ||
| 992 | void Application::updateProjectionMatrix() { | 1004 | void Application::updateProjectionMatrix() { |
| @@ -1824,7 +1836,7 @@ void Application::setFullscreen(bool fullscreen) { · 831 unmodified lines | |||
| 1824 | } | 1836 | } |
| 1825 | 1837 | ||
| 1826 | void Application::setEnable3DTVMode(bool enable3DTVMode) { | 1838 | void Application::setEnable3DTVMode(bool enable3DTVMode) { |
| 1827 | resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | 1839 | resizeGL(); |
| 1828 | } | 1840 | } |
| 1829 | 1841 | ||
| 1830 | void Application::setEnableVRMode(bool enableVRMode) { | 1842 | void Application::setEnableVRMode(bool enableVRMode) { |
| @@ -1849,7 +1861,7 @@ void Application::setEnableVRMode(bool enableVRMode) { · 18 unmodified lines | |||
| 1849 | _myCamera.setHmdRotation(glm::quat()); | 1861 | _myCamera.setHmdRotation(glm::quat()); |
| 1850 | } | 1862 | } |
| 1851 | 1863 | ||
| 1852 | resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | 1864 | resizeGL(); |
| 1853 | 1865 | ||
| 1854 | updateCursorVisibility(); | 1866 | updateCursorVisibility(); |
| 1855 | } | 1867 | } |
| @@ -3227,12 +3239,12 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 1371 unmodified lines | |||
| 3227 | _stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha); | 3239 | _stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha); |
| 3228 | } | 3240 | } |
| 3229 | 3241 | ||
| 3230 | // draw the sky dome | 3242 | // draw the sky dome |
| 3231 | if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { | 3243 | if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { |
| 3232 | PerformanceTimer perfTimer("atmosphere"); | 3244 | PerformanceTimer perfTimer("atmosphere"); |
| 3233 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 3245 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 3234 | "Application::displaySide() ... atmosphere..."); | 3246 | "Application::displaySide() ... atmosphere..."); |
| 3235 | _environment.renderAtmospheres(theCamera); | 3247 | _environment.renderAtmospheres(theCamera); |
| 3236 | } | 3248 | } |
| 3237 | 3249 | ||
| 3238 | } | 3250 | } |
| @@ -4635,7 +4647,3 @@ PickRay Application::computePickRay() const { · 1396 unmodified lines | |||
| 4635 | bool Application::hasFocus() const { | 4647 | bool Application::hasFocus() const { |
| 4636 | return _glWidget->hasFocus(); | 4648 | return _glWidget->hasFocus(); |
| 4637 | } | 4649 | } |
| 4638 | |||
| 4639 | void Application::resizeGL() { | ||
| 4640 | this->resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | ||
| 4641 | } | ||