History

Rendering resolution can be different than the native window resolution

- Get rid of the different GlowModes since we found the correct one (DIFFUSE and ADD) Get rid of the ui to change the mode - INtroduce a "RenderResolutionScale" in the application that controls the ratio ofthe resolution between the framebuffers and the native window provided by Qt - In the paintGL, in the default rendering path: the rendering Framebuffers are resized to the window.size * renderResolutionScale. The viewport is assigned to the framebuffer size from GlowEffect.prepare() to GlowEffect.render() (and not the original GLCanvas size) at the end of GLowEffect render, the final step is to blit the colorbuffer from the rendering into the window's default framebuffer at the original resolution, and that requires one more glViewport - add the ui in developer/render/ menu "scale resolution" where you can select the scaling level. THis should show in the rendering with ugly aliasing when selecting a scale under 1/2.

samcake committed 12 years ago

Commit 700ec5c1 parent f5ee55b8 files · +80 −123Browse files

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

Unified · Split

interface/src/Application.cpp+24−7
@@ -179,7 +179,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 178 unmodified lines
179179 _runningScriptsWidgetWasVisible(false),
180180 _trayIcon(new QSystemTrayIcon(_window)),
181181 _lastNackTime(usecTimestampNow()),
182− _lastSendDownstreamAudioStats(usecTimestampNow())
182+ _lastSendDownstreamAudioStats(usecTimestampNow()),
183+ _renderResolutionScale(1.0f)
183184 {
184185 // read the ApplicationInfo.ini file for Name/Version/Domain information
185186 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
@@ -598,7 +599,8 @@ void Application::paintGL() { · 412 unmodified lines
598599 if (OculusManager::isConnected()) {
599600 _textureCache.setFrameBufferSize(OculusManager::getRenderTargetSize());
600601 } else {
601− _textureCache.setFrameBufferSize(_glWidget->getDeviceSize());
602+ QSize fbSize = _glWidget->getDeviceSize() * _renderResolutionScale;
603+ _textureCache.setFrameBufferSize(fbSize);
602604 }
603605
604606 glEnable(GL_LINE_SMOOTH);
@@ -696,6 +698,10 @@ void Application::paintGL() { · 91 unmodified lines
696698 } else {
697699 _glowEffect.prepare();
698700
701+ // Viewport is assigned to the size of the framebuffer
702+ QSize size = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->size();
703+ glViewport( 0, 0, size.width(), size.height());
704+
699705 glMatrixMode(GL_MODELVIEW);
700706 glPushMatrix();
701707 glLoadIdentity();
@@ -3096,6 +3102,10 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 2394 unmodified lines
30963102 }
30973103
30983104 void Application::renderRearViewMirror(const QRect& region, bool billboard) {
3105+ // Grab current viewport to reset it at the end
3106+ int viewport[4];
3107+ glGetIntegerv(GL_VIEWPORT, viewport);
3108+
30993109 bool eyeRelativeCamera = false;
31003110 if (billboard) {
31013111 _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees
@@ -3127,14 +3137,17 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 25 unmodified lines
31273137
31283138 // set the bounds of rear mirror view
31293139 if (billboard) {
3130− glViewport(region.x(), _glWidget->getDeviceHeight() - region.y() - region.height(), region.width(), region.height());
3131− glScissor(region.x(), _glWidget->getDeviceHeight() - region.y() - region.height(), region.width(), region.height());
3140+ QSize size = getTextureCache()->getFrameBufferSize();
3141+ glViewport(region.x(), size.height() - region.y() - region.height(), region.width(), region.height());
3142+ glScissor(region.x(), size.height() - region.y() - region.height(), region.width(), region.height());
31323143 } else {
31333144 // if not rendering the billboard, the region is in device independent coordinates; must convert to device
3145+ QSize size = getTextureCache()->getFrameBufferSize();
31343146 float ratio = QApplication::desktop()->windowHandle()->devicePixelRatio();
3147+ ratio = size.height() / float(_glWidget->getDeviceHeight());
31353148 int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio;
3136− glViewport(x, _glWidget->getDeviceHeight() - y - height, width, height);
3137− glScissor(x, _glWidget->getDeviceHeight() - y - height, width, height);
3149+ glViewport(x, size.height() - y - height, width, height);
3150+ glScissor(x, size.height() - y - height, width, height);
31383151 }
31393152 bool updateViewFrustum = false;
31403153 updateProjectionMatrix(_mirrorCamera, updateViewFrustum);
@@ -3202,7 +3215,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 61 unmodified lines
32023215 }
32033216
32043217 // reset Viewport and projection matrix
3205− glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
3218+ glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
32063219 glDisable(GL_SCISSOR_TEST);
32073220 updateProjectionMatrix(_myCamera, updateViewFrustum);
32083221 }
@@ -4239,3 +4252,7 @@ void Application::takeSnapshot() { · 1030 unmodified lines
42394252 }
42404253 _snapshotShareDialog->show();
42414254 }
4255+
4256+void Application::setRenderResolutionScale(float scale) {
4257+ _renderResolutionScale = scale;
4258+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t