History

Merge pull request #4791 from jherico/scale

Fixing scale resolution issues

Brad Hefta-Gaub committed 11 years ago

Commit bfb2b272 parents 6008713 c31d36b13 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
@@ -812,8 +812,7 @@ void Application::initializeUi() { · 811 unmodified lines
812812 if (devicePixelRatio != oldDevicePixelRatio) {
813813 oldDevicePixelRatio = devicePixelRatio;
814814 qDebug() << "Device pixel ratio changed, triggering GL resize";
815− resizeGL(_glWidget->width(),
816− _glWidget->height());
815+ resizeGL();
817816 }
818817 });
819818 }
@@ -830,15 +829,7 @@ void Application::paintGL() { · 10 unmodified lines
830829 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
831830 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
832831 PerformanceWarning warn(showWarnings, "Application::paintGL()");
833−
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− }
832+ resizeGL();
842833
843834 glEnable(GL_LINE_SMOOTH);
844835
@@ -915,7 +906,14 @@ void Application::paintGL() { · 70 unmodified lines
915906 renderRearViewMirror(_mirrorViewRect);
916907 }
917908
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+
919917
920918 {
921919 PerformanceTimer perfTimer("renderOverlay");
@@ -960,33 +958,47 @@ void Application::showEditEntitiesHelp() { · 38 unmodified lines
960958 InfoView::show(INFO_EDIT_ENTITIES_PATH);
961959 }
962960
963−void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) {
961+void Application::resetCamerasOnResizeGL(Camera& camera, const glm::uvec2& size) {
964962 if (OculusManager::isConnected()) {
965− OculusManager::configureCamera(camera, width, height);
963+ OculusManager::configureCamera(camera, size.x, size.y);
966964 } else if (TV3DManager::isConnected()) {
967− TV3DManager::configureCamera(camera, width, height);
965+ TV3DManager::configureCamera(camera, size.x, size.y);
968966 } else {
969− camera.setAspectRatio((float)width / height);
967+ camera.setAspectRatio((float)size.x / size.y);
970968 camera.setFieldOfView(_fieldOfView.get());
971969 }
972970 }
973971
974−void Application::resizeGL(int width, int height) {
975− DependencyManager::get<TextureCache>()->setFrameBufferSize(QSize(width, height));
976− resetCamerasOnResizeGL(_myCamera, width, height);
972+void Application::resizeGL() {
973+ // Set the desired FBO texture size. If it hasn't changed, this does nothing.
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);
977988
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???
979990
980991 updateProjectionMatrix();
981992 glLoadIdentity();
982993
983994 auto offscreenUi = DependencyManager::get<OffscreenUi>();
984995 offscreenUi->resize(_glWidget->size());
996+ _glWidget->makeCurrent();
985997
986998 // update Stats width
987999 // let's set horizontal offset to give stats some margin to mirror
9881000 int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
989− Stats::getInstance()->resetWidth(width, horizontalOffset);
1001+ Stats::getInstance()->resetWidth(_renderResolution.x, horizontalOffset);
9901002 }
9911003
9921004 void Application::updateProjectionMatrix() {
@@ -1824,7 +1836,7 @@ void Application::setFullscreen(bool fullscreen) { · 831 unmodified lines
18241836 }
18251837
18261838 void Application::setEnable3DTVMode(bool enable3DTVMode) {
1827− resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
1839+ resizeGL();
18281840 }
18291841
18301842 void Application::setEnableVRMode(bool enableVRMode) {
@@ -1849,7 +1861,7 @@ void Application::setEnableVRMode(bool enableVRMode) { · 18 unmodified lines
18491861 _myCamera.setHmdRotation(glm::quat());
18501862 }
18511863
1852− resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
1864+ resizeGL();
18531865
18541866 updateCursorVisibility();
18551867 }
@@ -3227,12 +3239,12 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 1371 unmodified lines
32273239 _stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha);
32283240 }
32293241
3230− // draw the sky dome
3231− if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
3232− PerformanceTimer perfTimer("atmosphere");
3233− PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3234− "Application::displaySide() ... atmosphere...");
3235− _environment.renderAtmospheres(theCamera);
3242+ // draw the sky dome
3243+ if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
3244+ PerformanceTimer perfTimer("atmosphere");
3245+ PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3246+ "Application::displaySide() ... atmosphere...");
3247+ _environment.renderAtmospheres(theCamera);
32363248 }
32373249
32383250 }
@@ -4635,7 +4647,3 @@ PickRay Application::computePickRay() const { · 1396 unmodified lines
46354647 bool Application::hasFocus() const {
46364648 return _glWidget->hasFocus();
46374649 }
4638−
4639−void Application::resizeGL() {
4640− this->resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
4641−}