History

Fixing scale resolution issues

Bradley Austin Davis committed 11 years ago

Commit c31d36b1 parent 12c26f913 files · +99 −71Browse files

Showing the changes to interface/src/Application.cpp (1 of 13 files). Show all

Unified · Split

interface/src/Application.cpp+41−33
@@ -807,8 +807,7 @@ void Application::initializeUi() { · 806 unmodified lines
807 if (devicePixelRatio != oldDevicePixelRatio) {807 if (devicePixelRatio != oldDevicePixelRatio) {
808 oldDevicePixelRatio = devicePixelRatio;808 oldDevicePixelRatio = devicePixelRatio;
809 qDebug() << "Device pixel ratio changed, triggering GL resize";809 qDebug() << "Device pixel ratio changed, triggering GL resize";
810 resizeGL(_glWidget->width(),810 resizeGL();
811 _glWidget->height());
812 }811 }
813 });812 });
814}813}
@@ -825,15 +824,7 @@ void Application::paintGL() { · 10 unmodified lines
825 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));824 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
826 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);825 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
827 PerformanceWarning warn(showWarnings, "Application::paintGL()");826 PerformanceWarning warn(showWarnings, "Application::paintGL()");
828 827 resizeGL();
829 // Set the desired FBO texture size. If it hasn't changed, this does nothing.
830 // Otherwise, it must rebuild the FBOs
831 if (OculusManager::isConnected()) {
832 DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize());
833 } else {
834 QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
835 DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize);
836 }
837 828
838 glEnable(GL_LINE_SMOOTH);829 glEnable(GL_LINE_SMOOTH);
839 830
@@ -910,7 +901,14 @@ void Application::paintGL() { · 70 unmodified lines
910 renderRearViewMirror(_mirrorViewRect); 901 renderRearViewMirror(_mirrorViewRect);
911 }902 }
912 903
913 DependencyManager::get<GlowEffect>()->render();904 auto finalFbo = DependencyManager::get<GlowEffect>()->render();
905
906 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
907 glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo));
908 glBlitFramebuffer(0, 0, _renderResolution.x, _renderResolution.y,
909 0, 0, _glWidget->getDeviceSize().width(), _glWidget->getDeviceSize().height(),
910 GL_COLOR_BUFFER_BIT, GL_NEAREST);
911
914 912
915 {913 {
916 PerformanceTimer perfTimer("renderOverlay");914 PerformanceTimer perfTimer("renderOverlay");
@@ -955,33 +953,47 @@ void Application::showEditEntitiesHelp() { · 38 unmodified lines
955 InfoView::show(INFO_EDIT_ENTITIES_PATH);953 InfoView::show(INFO_EDIT_ENTITIES_PATH);
956}954}
957 955
958void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) {956void Application::resetCamerasOnResizeGL(Camera& camera, const glm::uvec2& size) {
959 if (OculusManager::isConnected()) {957 if (OculusManager::isConnected()) {
960 OculusManager::configureCamera(camera, width, height);958 OculusManager::configureCamera(camera, size.x, size.y);
961 } else if (TV3DManager::isConnected()) {959 } else if (TV3DManager::isConnected()) {
962 TV3DManager::configureCamera(camera, width, height);960 TV3DManager::configureCamera(camera, size.x, size.y);
963 } else {961 } else {
964 camera.setAspectRatio((float)width / height);962 camera.setAspectRatio((float)size.x / size.y);
965 camera.setFieldOfView(_fieldOfView.get());963 camera.setFieldOfView(_fieldOfView.get());
966 }964 }
967}965}
968 966
969void Application::resizeGL(int width, int height) {967void Application::resizeGL() {
970 DependencyManager::get<TextureCache>()->setFrameBufferSize(QSize(width, height));968 // Set the desired FBO texture size. If it hasn't changed, this does nothing.
971 resetCamerasOnResizeGL(_myCamera, width, height);969 // Otherwise, it must rebuild the FBOs
970 QSize renderSize;
971 if (OculusManager::isConnected()) {
972 renderSize = OculusManager::getRenderTargetSize();
973 } else {
974 renderSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
975 }
976 if (_renderResolution == toGlm(renderSize)) {
977 return;
978 }
979
980 _renderResolution = toGlm(renderSize);
981 DependencyManager::get<TextureCache>()->setFrameBufferSize(renderSize);
982 resetCamerasOnResizeGL(_myCamera, _renderResolution);
972 983
973 glViewport(0, 0, width, height); // shouldn't this account for the menu???984 glViewport(0, 0, _renderResolution.x, _renderResolution.y); // shouldn't this account for the menu???
974 985
975 updateProjectionMatrix();986 updateProjectionMatrix();
976 glLoadIdentity();987 glLoadIdentity();
977 988
978 auto offscreenUi = DependencyManager::get<OffscreenUi>();989 auto offscreenUi = DependencyManager::get<OffscreenUi>();
979 offscreenUi->resize(_glWidget->size());990 offscreenUi->resize(_glWidget->size());
991 _glWidget->makeCurrent();
980 992
981 // update Stats width993 // update Stats width
982 // let's set horizontal offset to give stats some margin to mirror994 // let's set horizontal offset to give stats some margin to mirror
983 int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;995 int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
984 Stats::getInstance()->resetWidth(width, horizontalOffset);996 Stats::getInstance()->resetWidth(_renderResolution.x, horizontalOffset);
985}997}
986 998
987void Application::updateProjectionMatrix() {999void Application::updateProjectionMatrix() {
@@ -1819,7 +1831,7 @@ void Application::setFullscreen(bool fullscreen) { · 831 unmodified lines
1819}1831}
1820 1832
1821void Application::setEnable3DTVMode(bool enable3DTVMode) {1833void Application::setEnable3DTVMode(bool enable3DTVMode) {
1822 resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());1834 resizeGL();
1823}1835}
1824 1836
1825void Application::setEnableVRMode(bool enableVRMode) {1837void Application::setEnableVRMode(bool enableVRMode) {
@@ -1844,7 +1856,7 @@ void Application::setEnableVRMode(bool enableVRMode) { · 18 unmodified lines
1844 _myCamera.setHmdRotation(glm::quat());1856 _myCamera.setHmdRotation(glm::quat());
1845 }1857 }
1846 1858
1847 resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());1859 resizeGL();
1848 1860
1849 updateCursorVisibility();1861 updateCursorVisibility();
1850}1862}
@@ -3200,12 +3212,12 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 1349 unmodified lines
3200 _stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha);3212 _stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha);
3201 }3213 }
3202 3214
3203 // draw the sky dome3215 // draw the sky dome
3204 if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {3216 if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
3205 PerformanceTimer perfTimer("atmosphere");3217 PerformanceTimer perfTimer("atmosphere");
3206 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),3218 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3207 "Application::displaySide() ... atmosphere...");3219 "Application::displaySide() ... atmosphere...");
3208 _environment.renderAtmospheres(theCamera);3220 _environment.renderAtmospheres(theCamera);
3209 }3221 }
3210 3222
3211 }3223 }
@@ -4605,7 +4617,3 @@ PickRay Application::computePickRay() const { · 1393 unmodified lines
4605bool Application::hasFocus() const {4617bool Application::hasFocus() const {
4606 return _glWidget->hasFocus();4618 return _glWidget->hasFocus();
4607}4619}
4608
4609void Application::resizeGL() {
4610 this->resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
4611}