History

Fix the problem of actual framerate target not beeing true to the value displayed in the menu, same for resolution scale. Removed the value in Application and relies exclusively on the menu state

Sam Gateau committed 12 years ago

Commit cecf79e1 parent b246af74 files · +82 −75Browse files

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

Unified · Split

interface/src/Application.cpp+70−19
@@ -107,8 +107,6 @@ static unsigned STARFIELD_SEED = 1; · 106 unmodified lines
107107
108108 static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
109109
110−const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff
111− // in the idle loop? (60 FPS is default)
112110 static QTimer* idleTimer = NULL;
113111
114112 const QString CHECK_VERSION_URL = "https://highfidelity.io/latestVersion.xml";
@@ -182,9 +180,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 67 unmodified lines
182180 _trayIcon(new QSystemTrayIcon(_window)),
183181 _lastNackTime(usecTimestampNow()),
184182 _lastSendDownstreamAudioStats(usecTimestampNow()),
185− _renderTargetFramerate(0),
186− _isVSyncOn(true),
187− _renderResolutionScale(1.0f)
183+ _isVSyncOn(true)
188184 {
189185
190186 // read the ApplicationInfo.ini file for Name/Version/Domain information
@@ -601,7 +597,7 @@ void Application::paintGL() { · 410 unmodified lines
601597 if (OculusManager::isConnected()) {
602598 _textureCache.setFrameBufferSize(OculusManager::getRenderTargetSize());
603599 } else {
604− QSize fbSize = _glWidget->getDeviceSize() * _renderResolutionScale;
600+ QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
605601 _textureCache.setFrameBufferSize(fbSize);
606602 }
607603
@@ -1471,12 +1467,11 @@ void Application::idle() { · 863 unmodified lines
14711467 bool showWarnings = getLogger()->extraDebugging();
14721468 PerformanceWarning warn(showWarnings, "idle()");
14731469
1474− // Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran
1470+ // Only run simulation code if more than the targetFramePeriod have passed since last time we ran
14751471 double targetFramePeriod = 0.0;
1476− if (_renderTargetFramerate > 0) {
1477− targetFramePeriod = 1000.0 / _renderTargetFramerate;
1478− } else if (_renderTargetFramerate < 0) {
1479− targetFramePeriod = IDLE_SIMULATE_MSECS;
1472+ unsigned int targetFramerate = getRenderTargetFramerate();
1473+ if (targetFramerate > 0) {
1474+ targetFramePeriod = 1000.0 / targetFramerate;
14801475 }
14811476 double timeSinceLastUpdate = (double)_lastTimeUpdated.nsecsElapsed() / 1000000.0;
14821477 if (timeSinceLastUpdate > targetFramePeriod) {
@@ -3176,7 +3171,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 1693 unmodified lines
31763171 } else {
31773172 // if not rendering the billboard, the region is in device independent coordinates; must convert to device
31783173 QSize size = getTextureCache()->getFrameBufferSize();
3179− float ratio = QApplication::desktop()->windowHandle()->devicePixelRatio() * _renderResolutionScale;
3174+ float ratio = QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale();
31803175 int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio;
31813176 glViewport(x, size.height() - y - height, width, height);
31823177 glScissor(x, size.height() - y - height, width, height);
@@ -4234,13 +4229,11 @@ void Application::takeSnapshot() { · 1051 unmodified lines
42344229 _snapshotShareDialog->show();
42354230 }
42364231
4237−void Application::setRenderTargetFramerate(unsigned int framerate, bool vsyncOn) {
4238− if (vsyncOn != _isVSyncOn) {
4232+void Application::setVSyncEnabled(bool vsyncOn) {
42394233 #if defined(Q_OS_WIN)
42404234 if (wglewGetExtension("WGL_EXT_swap_control")) {
42414235 wglSwapIntervalEXT(vsyncOn);
42424236 int swapInterval = wglGetSwapIntervalEXT();
4243− _isVSyncOn = swapInterval;
42444237 qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
42454238 } else {
42464239 qDebug("V-Sync is FORCED ON on this system\n");
@@ -4260,11 +4253,32 @@ void Application::setRenderTargetFramerate(unsigned int framerate, bool vsyncOn) · 13 unmodified lines
42604253 #else
42614254 qDebug("V-Sync is FORCED ON on this system\n");
42624255 #endif
4256+}
4257+
4258+bool Application::isVSyncOn() const {
4259+#if defined(Q_OS_WIN)
4260+ if (wglewGetExtension("WGL_EXT_swap_control")) {
4261+ int swapInterval = wglGetSwapIntervalEXT();
4262+ return (swapInterval > 0);
4263+ } else {
4264+ return true;
42634265 }
4264− _renderTargetFramerate = framerate;
4266+#elif defined(Q_OS_LINUX)
4267+ // TODO: write the poper code for linux
4268+ /*
4269+ if (glQueryExtension.... ("GLX_EXT_swap_control")) {
4270+ int swapInterval = xglGetSwapIntervalEXT();
4271+ return (swapInterval > 0);
4272+ } else {
4273+ return true;
4274+ }
4275+ */
4276+#else
4277+ return true;
4278+#endif
42654279 }
42664280
4267−bool Application::isVSyncEditable() {
4281+bool Application::isVSyncEditable() const {
42684282 #if defined(Q_OS_WIN)
42694283 if (wglewGetExtension("WGL_EXT_swap_control")) {
42704284 return true;
@@ -4281,6 +4295,43 @@ bool Application::isVSyncEditable() { · 10 unmodified lines
42814295 return false;
42824296 }
42834297
4284−void Application::setRenderResolutionScale(float scale) {
4285− _renderResolutionScale = scale;
4298+unsigned int Application::getRenderTargetFramerate() const {
4299+ if (Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerateUnlimited)) {
4300+ return 0;
4301+ }
4302+ else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerate60)) {
4303+ return 60;
4304+ }
4305+ else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerate50)) {
4306+ return 50;
4307+ }
4308+ else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerate40)) {
4309+ return 40;
4310+ }
4311+ else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerate30)) {
4312+ return 30;
4313+ }
4314+ return 0;
42864315 }
4316+
4317+float Application::getRenderResolutionScale() const {
4318+
4319+ if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionOne)) {
4320+ return 1.f;
4321+ }
4322+ else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionTwoThird)) {
4323+ return 0.666f;
4324+ }
4325+ else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionHalf)) {
4326+ return 0.5f;
4327+ }
4328+ else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionThird)) {
4329+ return 0.333f;
4330+ }
4331+ else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionQuarter)) {
4332+ return 0.25f;
4333+ }
4334+ else {
4335+ return 1.f;
4336+ }
4337+}

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