Showing the changes to interface/src/Application.cpp (1 of 6 files). Show all
Unified · Split
| @@ -94,10 +94,6 @@ · 93 unmodified lines | |||
| 94 | 94 | ||
| 95 | #include "devices/Leapmotion.h" | 95 | #include "devices/Leapmotion.h" |
| 96 | 96 | ||
| 97 | #ifdef WIN32 | ||
| 98 | #include <gl/wglew.h> | ||
| 99 | #endif | ||
| 100 | |||
| 101 | using namespace std; | 97 | using namespace std; |
| 102 | 98 | ||
| 103 | // Starfield information | 99 | // Starfield information |
| @@ -183,17 +179,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 79 unmodified lines | |||
| 183 | _trayIcon(new QSystemTrayIcon(_window)), | 179 | _trayIcon(new QSystemTrayIcon(_window)), |
| 184 | _lastNackTime(usecTimestampNow()), | 180 | _lastNackTime(usecTimestampNow()), |
| 185 | _lastSendDownstreamAudioStats(usecTimestampNow()), | 181 | _lastSendDownstreamAudioStats(usecTimestampNow()), |
| 186 | _renderTargetFramerate(60), | 182 | _renderTargetFramerate(0), |
| 183 | _isVSyncOn(true), | ||
| 187 | _renderResolutionScale(1.0f) | 184 | _renderResolutionScale(1.0f) |
| 188 | { | 185 | { |
| 189 | 186 | ||
| 190 | |||
| 191 | /* QGLFormat trueFormat = _glWidget->format(); | ||
| 192 | trueFormat.setSwapInterval(0); | ||
| 193 | _glWidget->setFormat(trueFormat);*/ | ||
| 194 | int swapInterval = _glWidget->format().swapInterval(); | ||
| 195 | swapInterval++; | ||
| 196 | |||
| 197 | // read the ApplicationInfo.ini file for Name/Version/Domain information | 187 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 198 | QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); | 188 | QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); |
| 199 | 189 | ||
| @@ -535,13 +525,18 @@ void Application::initializeGL() { · 335 unmodified lines | |||
| 535 | qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); | 525 | qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); |
| 536 | 526 | ||
| 537 | if (wglewGetExtension("WGL_EXT_swap_control")) { | 527 | if (wglewGetExtension("WGL_EXT_swap_control")) { |
| 538 | wglSwapIntervalEXT(0); | ||
| 539 | int swapInterval = wglGetSwapIntervalEXT(); | 528 | int swapInterval = wglGetSwapIntervalEXT(); |
| 540 | swapInterval++; | 529 | qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF")); |
| 541 | } | 530 | } |
| 542 | #endif | 531 | #endif |
| 543 | 532 | ||
| 544 | 533 | #if defined(Q_OS_LINUX) | |
| 534 | // TODO: Write the correct code for Linux... | ||
| 535 | /* if (wglewGetExtension("WGL_EXT_swap_control")) { | ||
| 536 | int swapInterval = wglGetSwapIntervalEXT(); | ||
| 537 | qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF")); | ||
| 538 | }*/ | ||
| 539 | #endif | ||
| 545 | 540 | ||
| 546 | // Before we render anything, let's set up our viewFrustumOffsetCamera with a sufficiently large | 541 | // Before we render anything, let's set up our viewFrustumOffsetCamera with a sufficiently large |
| 547 | // field of view and near and far clip to make it interesting. | 542 | // field of view and near and far clip to make it interesting. |
| @@ -4168,10 +4163,53 @@ void Application::takeSnapshot() { · 3620 unmodified lines | |||
| 4168 | _snapshotShareDialog->show(); | 4163 | _snapshotShareDialog->show(); |
| 4169 | } | 4164 | } |
| 4170 | 4165 | ||
| 4171 | void Application::setRenderTargetFramerate(int framerate) { | 4166 | void Application::setRenderTargetFramerate(unsigned int framerate, bool vsyncOn) { |
| 4167 | if (vsyncOn != _isVSyncOn) { | ||
| 4168 | #if defined(Q_OS_WIN) | ||
| 4169 | if (wglewGetExtension("WGL_EXT_swap_control")) { | ||
| 4170 | wglSwapIntervalEXT(vsyncOn); | ||
| 4171 | int swapInterval = wglGetSwapIntervalEXT(); | ||
| 4172 | _isVSyncOn = swapInterval; | ||
| 4173 | qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF")); | ||
| 4174 | } else { | ||
| 4175 | qDebug("V-Sync is FORCED ON on this system\n"); | ||
| 4176 | } | ||
| 4177 | #elif defined(Q_OS_LINUX) | ||
| 4178 | // TODO: write the poper code for linux | ||
| 4179 | /* | ||
| 4180 | if (glQueryExtension.... ("GLX_EXT_swap_control")) { | ||
| 4181 | glxSwapIntervalEXT(vsyncOn); | ||
| 4182 | int swapInterval = xglGetSwapIntervalEXT(); | ||
| 4183 | _isVSyncOn = swapInterval; | ||
| 4184 | qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF")); | ||
| 4185 | } else { | ||
| 4186 | qDebug("V-Sync is FORCED ON on this system\n"); | ||
| 4187 | } | ||
| 4188 | */ | ||
| 4189 | #else | ||
| 4190 | qDebug("V-Sync is FORCED ON on this system\n"); | ||
| 4191 | #endif | ||
| 4192 | } | ||
| 4172 | _renderTargetFramerate = framerate; | 4193 | _renderTargetFramerate = framerate; |
| 4173 | } | 4194 | } |
| 4174 | 4195 | ||
| 4196 | bool Application::isVSyncEditable() { | ||
| 4197 | #if defined(Q_OS_WIN) | ||
| 4198 | if (wglewGetExtension("WGL_EXT_swap_control")) { | ||
| 4199 | return true; | ||
| 4200 | } | ||
| 4201 | #elif defined(Q_OS_LINUX) | ||
| 4202 | // TODO: write the poper code for linux | ||
| 4203 | /* | ||
| 4204 | if (glQueryExtension.... ("GLX_EXT_swap_control")) { | ||
| 4205 | return true; | ||
| 4206 | } | ||
| 4207 | */ | ||
| 4208 | #else | ||
| 4209 | #endif | ||
| 4210 | return false; | ||
| 4211 | } | ||
| 4212 | |||
| 4175 | void Application::setRenderResolutionScale(float scale) { | 4213 | void Application::setRenderResolutionScale(float scale) { |
| 4176 | _renderResolutionScale = scale; | 4214 | _renderResolutionScale = scale; |
| 4177 | } | 4215 | } |