Showing the changes to interface/src/Application.cpp (1 of 9 files). Show all
Unified · Split
| @@ -35,6 +35,7 @@ · 34 unmodified lines | |||
| 35 | #include <QMenuBar> | 35 | #include <QMenuBar> |
| 36 | #include <QMouseEvent> | 36 | #include <QMouseEvent> |
| 37 | #include <QNetworkAccessManager> | 37 | #include <QNetworkAccessManager> |
| 38 | #include <QOpenGLFramebufferObject> | ||
| 38 | #include <QWheelEvent> | 39 | #include <QWheelEvent> |
| 39 | #include <QSettings> | 40 | #include <QSettings> |
| 40 | #include <QShortcut> | 41 | #include <QShortcut> |
| @@ -112,7 +113,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 71 unmodified lines | |||
| 112 | _lookatIndicatorScale(1.0f), | 113 | _lookatIndicatorScale(1.0f), |
| 113 | _perfStatsOn(false), | 114 | _perfStatsOn(false), |
| 114 | _chatEntryOn(false), | 115 | _chatEntryOn(false), |
| 115 | _oculusTextureID(0), | ||
| 116 | _oculusProgram(0), | 116 | _oculusProgram(0), |
| 117 | _oculusDistortionScale(1.25), | 117 | _oculusDistortionScale(1.25), |
| 118 | #ifndef _WIN32 | 118 | #ifndef _WIN32 |
| @@ -370,13 +370,18 @@ void Application::paintGL() { · 251 unmodified lines | |||
| 370 | 370 | ||
| 371 | if (OculusManager::isConnected()) { | 371 | if (OculusManager::isConnected()) { |
| 372 | displayOculus(whichCamera); | 372 | displayOculus(whichCamera); |
| 373 | |||
| 373 | } else { | 374 | } else { |
| 375 | _glowEffect.prepare(); | ||
| 376 | |||
| 374 | glMatrixMode(GL_MODELVIEW); | 377 | glMatrixMode(GL_MODELVIEW); |
| 375 | glPushMatrix(); | 378 | glPushMatrix(); |
| 376 | glLoadIdentity(); | 379 | glLoadIdentity(); |
| 377 | displaySide(whichCamera); | 380 | displaySide(whichCamera); |
| 378 | glPopMatrix(); | 381 | glPopMatrix(); |
| 379 | 382 | ||
| 383 | _glowEffect.render(); | ||
| 384 | |||
| 380 | displayOverlay(); | 385 | displayOverlay(); |
| 381 | } | 386 | } |
| 382 | 387 | ||
| @@ -400,13 +405,6 @@ void Application::resizeGL(int width, int height) { · 17 unmodified lines | |||
| 400 | resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height); | 405 | resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height); |
| 401 | resetCamerasOnResizeGL(_myCamera, width, height); | 406 | resetCamerasOnResizeGL(_myCamera, width, height); |
| 402 | 407 | ||
| 403 | // resize the render texture | ||
| 404 | if (OculusManager::isConnected() && _oculusTextureID != 0) { | ||
| 405 | glBindTexture(GL_TEXTURE_2D, _oculusTextureID); | ||
| 406 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); | ||
| 407 | glBindTexture(GL_TEXTURE_2D, 0); | ||
| 408 | } | ||
| 409 | |||
| 410 | // Tell our viewFrustum about this change, using the application camera | 408 | // Tell our viewFrustum about this change, using the application camera |
| 411 | loadViewFrustum(_myCamera, _viewFrustum); | 409 | loadViewFrustum(_myCamera, _viewFrustum); |
| 412 | 410 | ||
| @@ -2056,6 +2054,8 @@ static const char* DISTORTION_FRAGMENT_SHADER = · 1643 unmodified lines | |||
| 2056 | "}"; | 2054 | "}"; |
| 2057 | 2055 | ||
| 2058 | void Application::displayOculus(Camera& whichCamera) { | 2056 | void Application::displayOculus(Camera& whichCamera) { |
| 2057 | _glowEffect.prepare(); | ||
| 2058 | |||
| 2059 | // magic numbers ahoy! in order to avoid pulling in the Oculus utility library that calculates | 2059 | // magic numbers ahoy! in order to avoid pulling in the Oculus utility library that calculates |
| 2060 | // the rendering parameters from the hardware stats, i just folded their calculations into | 2060 | // the rendering parameters from the hardware stats, i just folded their calculations into |
| 2061 | // constants using the stats for the current-model hardware as contained in the SDK file | 2061 | // constants using the stats for the current-model hardware as contained in the SDK file |
| @@ -2098,12 +2098,10 @@ void Application::displayOculus(Camera& whichCamera) { · 36 unmodified lines | |||
| 2098 | // restore our normal viewport | 2098 | // restore our normal viewport |
| 2099 | glViewport(0, 0, _glWidget->width(), _glWidget->height()); | 2099 | glViewport(0, 0, _glWidget->width(), _glWidget->height()); |
| 2100 | 2100 | ||
| 2101 | if (_oculusTextureID == 0) { | 2101 | QOpenGLFramebufferObject* fbo = _glowEffect.render(true); |
| 2102 | glGenTextures(1, &_oculusTextureID); | 2102 | glBindTexture(GL_TEXTURE_2D, fbo->texture()); |
| 2103 | glBindTexture(GL_TEXTURE_2D, _oculusTextureID); | 2103 | |
| 2104 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _glWidget->width(), _glWidget->height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); | 2104 | if (_oculusProgram == 0) { |
| 2105 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | ||
| 2106 | |||
| 2107 | _oculusProgram = new ProgramObject(); | 2105 | _oculusProgram = new ProgramObject(); |
| 2108 | _oculusProgram->addShaderFromSourceCode(QGLShader::Fragment, DISTORTION_FRAGMENT_SHADER); | 2106 | _oculusProgram->addShaderFromSourceCode(QGLShader::Fragment, DISTORTION_FRAGMENT_SHADER); |
| 2109 | _oculusProgram->link(); | 2107 | _oculusProgram->link(); |
| @@ -2113,18 +2111,13 @@ void Application::displayOculus(Camera& whichCamera) { · 3 unmodified lines | |||
| 2113 | _screenCenterLocation = _oculusProgram->uniformLocation("screenCenter"); | 2111 | _screenCenterLocation = _oculusProgram->uniformLocation("screenCenter"); |
| 2114 | _scaleLocation = _oculusProgram->uniformLocation("scale"); | 2112 | _scaleLocation = _oculusProgram->uniformLocation("scale"); |
| 2115 | _scaleInLocation = _oculusProgram->uniformLocation("scaleIn"); | 2113 | _scaleInLocation = _oculusProgram->uniformLocation("scaleIn"); |
| 2116 | _hmdWarpParamLocation = _oculusProgram->uniformLocation("hmdWarpParam"); | 2114 | _hmdWarpParamLocation = _oculusProgram->uniformLocation("hmdWarpParam"); |
| 2117 | |||
| 2118 | } else { | ||
| 2119 | glBindTexture(GL_TEXTURE_2D, _oculusTextureID); | ||
| 2120 | } | 2115 | } |
| 2121 | glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, _glWidget->width(), _glWidget->height()); | 2116 | |
| 2122 | |||
| 2123 | glMatrixMode(GL_PROJECTION); | 2117 | glMatrixMode(GL_PROJECTION); |
| 2124 | glLoadIdentity(); | 2118 | glLoadIdentity(); |
| 2125 | gluOrtho2D(0, _glWidget->width(), 0, _glWidget->height()); | 2119 | gluOrtho2D(0, _glWidget->width(), 0, _glWidget->height()); |
| 2126 | glDisable(GL_DEPTH_TEST); | 2120 | glDisable(GL_DEPTH_TEST); |
| 2127 | glDisable(GL_LIGHTING); | ||
| 2128 | 2121 | ||
| 2129 | // for reference on setting these values, see SDK file Samples/OculusRoomTiny/RenderTiny_Device.cpp | 2122 | // for reference on setting these values, see SDK file Samples/OculusRoomTiny/RenderTiny_Device.cpp |
| 2130 | 2123 | ||
| @@ -2132,7 +2125,6 @@ void Application::displayOculus(Camera& whichCamera) { · 1 unmodified line | |||
| 2132 | float aspectRatio = (_glWidget->width() * 0.5) / _glWidget->height(); | 2125 | float aspectRatio = (_glWidget->width() * 0.5) / _glWidget->height(); |
| 2133 | 2126 | ||
| 2134 | glDisable(GL_BLEND); | 2127 | glDisable(GL_BLEND); |
| 2135 | glEnable(GL_TEXTURE_2D); | ||
| 2136 | _oculusProgram->bind(); | 2128 | _oculusProgram->bind(); |
| 2137 | _oculusProgram->setUniformValue(_textureLocation, 0); | 2129 | _oculusProgram->setUniformValue(_textureLocation, 0); |
| 2138 | _oculusProgram->setUniformValue(_lensCenterLocation, 0.287994, 0.5); // see SDK docs, p. 29 | 2130 | _oculusProgram->setUniformValue(_lensCenterLocation, 0.287994, 0.5); // see SDK docs, p. 29 |
| @@ -2168,7 +2160,6 @@ void Application::displayOculus(Camera& whichCamera) { · 29 unmodified lines | |||
| 2168 | glEnd(); | 2160 | glEnd(); |
| 2169 | 2161 | ||
| 2170 | glEnable(GL_BLEND); | 2162 | glEnable(GL_BLEND); |
| 2171 | glDisable(GL_TEXTURE_2D); | ||
| 2172 | glBindTexture(GL_TEXTURE_2D, 0); | 2163 | glBindTexture(GL_TEXTURE_2D, 0); |
| 2173 | _oculusProgram->release(); | 2164 | _oculusProgram->release(); |
| 2174 | 2165 | ||
| @@ -2229,9 +2220,6 @@ void Application::displaySide(Camera& whichCamera) { · 54 unmodified lines | |||
| 2229 | // Setup 3D lights (after the camera transform, so that they are positioned in world space) | 2220 | // Setup 3D lights (after the camera transform, so that they are positioned in world space) |
| 2230 | setupWorldLight(whichCamera); | 2221 | setupWorldLight(whichCamera); |
| 2231 | 2222 | ||
| 2232 | // prepare the glow effect | ||
| 2233 | _glowEffect.prepare(); | ||
| 2234 | |||
| 2235 | if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) { | 2223 | if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) { |
| 2236 | if (!_stars.getFileLoaded()) { | 2224 | if (!_stars.getFileLoaded()) { |
| 2237 | _stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0); | 2225 | _stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0); |
| @@ -2372,7 +2360,7 @@ void Application::displaySide(Camera& whichCamera) { · 134 unmodified lines | |||
| 2372 | _myAvatar.renderScreenTint(SCREEN_TINT_AFTER_AVATARS, whichCamera); | 2360 | _myAvatar.renderScreenTint(SCREEN_TINT_AFTER_AVATARS, whichCamera); |
| 2373 | 2361 | ||
| 2374 | // Render the world box | 2362 | // Render the world box |
| 2375 | if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror) && Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { | 2363 | if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror) && Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { |
| 2376 | renderWorldBox(); | 2364 | renderWorldBox(); |
| 2377 | } | 2365 | } |
| 2378 | 2366 | ||
| @@ -2399,9 +2387,6 @@ void Application::displaySide(Camera& whichCamera) { · 20 unmodified lines | |||
| 2399 | } | 2387 | } |
| 2400 | 2388 | ||
| 2401 | renderFollowIndicator(); | 2389 | renderFollowIndicator(); |
| 2402 | |||
| 2403 | // render the glow effect | ||
| 2404 | _glowEffect.render(); | ||
| 2405 | } | 2390 | } |
| 2406 | 2391 | ||
| 2407 | void Application::displayOverlay() { | 2392 | void Application::displayOverlay() { |