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
807807 if (devicePixelRatio != oldDevicePixelRatio) {
808808 oldDevicePixelRatio = devicePixelRatio;
809809 qDebug() << "Device pixel ratio changed, triggering GL resize";
810− resizeGL(_glWidget->width(),
811− _glWidget->height());
810+ resizeGL();
812811 }
813812 });
814813 }
@@ -825,15 +824,7 @@ void Application::paintGL() { · 10 unmodified lines
825824 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
826825 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
827826 PerformanceWarning warn(showWarnings, "Application::paintGL()");
828−
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− }
827+ resizeGL();
837828
838829 glEnable(GL_LINE_SMOOTH);
839830
@@ -910,7 +901,14 @@ void Application::paintGL() { · 70 unmodified lines
910901 renderRearViewMirror(_mirrorViewRect);
911902 }
912903
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+
914912
915913 {
916914 PerformanceTimer perfTimer("renderOverlay");
@@ -955,33 +953,47 @@ void Application::showEditEntitiesHelp() { · 38 unmodified lines
955953 InfoView::show(INFO_EDIT_ENTITIES_PATH);
956954 }
957955
958−void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) {
956+void Application::resetCamerasOnResizeGL(Camera& camera, const glm::uvec2& size) {
959957 if (OculusManager::isConnected()) {
960− OculusManager::configureCamera(camera, width, height);
958+ OculusManager::configureCamera(camera, size.x, size.y);
961959 } else if (TV3DManager::isConnected()) {
962− TV3DManager::configureCamera(camera, width, height);
960+ TV3DManager::configureCamera(camera, size.x, size.y);
963961 } else {
964− camera.setAspectRatio((float)width / height);
962+ camera.setAspectRatio((float)size.x / size.y);
965963 camera.setFieldOfView(_fieldOfView.get());
966964 }
967965 }
968966
969−void Application::resizeGL(int width, int height) {
970− DependencyManager::get<TextureCache>()->setFrameBufferSize(QSize(width, height));
971− resetCamerasOnResizeGL(_myCamera, width, height);
967+void Application::resizeGL() {
968+ // Set the desired FBO texture size. If it hasn't changed, this does nothing.
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);
972983
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???
974985
975986 updateProjectionMatrix();
976987 glLoadIdentity();
977988
978989 auto offscreenUi = DependencyManager::get<OffscreenUi>();
979990 offscreenUi->resize(_glWidget->size());
991+ _glWidget->makeCurrent();
980992
981993 // update Stats width
982994 // let's set horizontal offset to give stats some margin to mirror
983995 int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
984− Stats::getInstance()->resetWidth(width, horizontalOffset);
996+ Stats::getInstance()->resetWidth(_renderResolution.x, horizontalOffset);
985997 }
986998
987999 void Application::updateProjectionMatrix() {
@@ -1819,7 +1831,7 @@ void Application::setFullscreen(bool fullscreen) { · 831 unmodified lines
18191831 }
18201832
18211833 void Application::setEnable3DTVMode(bool enable3DTVMode) {
1822− resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
1834+ resizeGL();
18231835 }
18241836
18251837 void Application::setEnableVRMode(bool enableVRMode) {
@@ -1844,7 +1856,7 @@ void Application::setEnableVRMode(bool enableVRMode) { · 18 unmodified lines
18441856 _myCamera.setHmdRotation(glm::quat());
18451857 }
18461858
1847− resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
1859+ resizeGL();
18481860
18491861 updateCursorVisibility();
18501862 }
@@ -3200,12 +3212,12 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 1349 unmodified lines
32003212 _stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha);
32013213 }
32023214
3203− // draw the sky dome
3204− if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
3205− PerformanceTimer perfTimer("atmosphere");
3206− PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3207− "Application::displaySide() ... atmosphere...");
3208− _environment.renderAtmospheres(theCamera);
3215+ // draw the sky dome
3216+ if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
3217+ PerformanceTimer perfTimer("atmosphere");
3218+ PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3219+ "Application::displaySide() ... atmosphere...");
3220+ _environment.renderAtmospheres(theCamera);
32093221 }
32103222
32113223 }
@@ -4605,7 +4617,3 @@ PickRay Application::computePickRay() const { · 1393 unmodified lines
46054617 bool Application::hasFocus() const {
46064618 return _glWidget->hasFocus();
46074619 }
4608−
4609−void Application::resizeGL() {
4610− this->resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
4611−}