History

framerate is as fast as the display can go

Sam Gateau committed 12 years ago

Commit 80a87b31 parent 5b0fd996 files · +114 −27Browse files

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

Unified · Split

interface/src/Application.cpp+54−16
@@ -94,10 +94,6 @@ · 93 unmodified lines
9494
9595 #include "devices/Leapmotion.h"
9696
97−#ifdef WIN32
98−#include <gl/wglew.h>
99−#endif
100−
10197 using namespace std;
10298
10399 // Starfield information
@@ -183,17 +179,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 79 unmodified lines
183179 _trayIcon(new QSystemTrayIcon(_window)),
184180 _lastNackTime(usecTimestampNow()),
185181 _lastSendDownstreamAudioStats(usecTimestampNow()),
186− _renderTargetFramerate(60),
182+ _renderTargetFramerate(0),
183+ _isVSyncOn(true),
187184 _renderResolutionScale(1.0f)
188185 {
189186
190−
191− /* QGLFormat trueFormat = _glWidget->format();
192− trueFormat.setSwapInterval(0);
193− _glWidget->setFormat(trueFormat);*/
194− int swapInterval = _glWidget->format().swapInterval();
195− swapInterval++;
196−
197187 // read the ApplicationInfo.ini file for Name/Version/Domain information
198188 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
199189
@@ -535,13 +525,18 @@ void Application::initializeGL() { · 335 unmodified lines
535525 qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
536526
537527 if (wglewGetExtension("WGL_EXT_swap_control")) {
538− wglSwapIntervalEXT(0);
539528 int swapInterval = wglGetSwapIntervalEXT();
540− swapInterval++;
529+ qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
541530 }
542531 #endif
543532
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
545540
546541 // Before we render anything, let's set up our viewFrustumOffsetCamera with a sufficiently large
547542 // field of view and near and far clip to make it interesting.
@@ -4168,10 +4163,53 @@ void Application::takeSnapshot() { · 3620 unmodified lines
41684163 _snapshotShareDialog->show();
41694164 }
41704165
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+ }
41724193 _renderTargetFramerate = framerate;
41734194 }
41744195
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+
41754213 void Application::setRenderResolutionScale(float scale) {
41764214 _renderResolutionScale = scale;
41774215 }

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