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