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
107 107
108static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored108static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
109 109
110const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff
111 // in the idle loop? (60 FPS is default)
112static QTimer* idleTimer = NULL;110static QTimer* idleTimer = NULL;
113 111
114const QString CHECK_VERSION_URL = "https://highfidelity.io/latestVersion.xml";112const 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
182 _trayIcon(new QSystemTrayIcon(_window)),180 _trayIcon(new QSystemTrayIcon(_window)),
183 _lastNackTime(usecTimestampNow()),181 _lastNackTime(usecTimestampNow()),
184 _lastSendDownstreamAudioStats(usecTimestampNow()),182 _lastSendDownstreamAudioStats(usecTimestampNow()),
185 _renderTargetFramerate(0),183 _isVSyncOn(true)
186 _isVSyncOn(true),
187 _renderResolutionScale(1.0f)
188{184{
189 185
190 // read the ApplicationInfo.ini file for Name/Version/Domain information186 // read the ApplicationInfo.ini file for Name/Version/Domain information
@@ -601,7 +597,7 @@ void Application::paintGL() { · 410 unmodified lines
601 if (OculusManager::isConnected()) {597 if (OculusManager::isConnected()) {
602 _textureCache.setFrameBufferSize(OculusManager::getRenderTargetSize());598 _textureCache.setFrameBufferSize(OculusManager::getRenderTargetSize());
603 } else {599 } else {
604 QSize fbSize = _glWidget->getDeviceSize() * _renderResolutionScale;600 QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
605 _textureCache.setFrameBufferSize(fbSize);601 _textureCache.setFrameBufferSize(fbSize);
606 }602 }
607 603
@@ -1471,12 +1467,11 @@ void Application::idle() { · 863 unmodified lines
1471 bool showWarnings = getLogger()->extraDebugging();1467 bool showWarnings = getLogger()->extraDebugging();
1472 PerformanceWarning warn(showWarnings, "idle()");1468 PerformanceWarning warn(showWarnings, "idle()");
1473 1469
1474 // Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran1470 // Only run simulation code if more than the targetFramePeriod have passed since last time we ran
1475 double targetFramePeriod = 0.0;1471 double targetFramePeriod = 0.0;
1476 if (_renderTargetFramerate > 0) {1472 unsigned int targetFramerate = getRenderTargetFramerate();
1477 targetFramePeriod = 1000.0 / _renderTargetFramerate;1473 if (targetFramerate > 0) {
1478 } else if (_renderTargetFramerate < 0) {1474 targetFramePeriod = 1000.0 / targetFramerate;
1479 targetFramePeriod = IDLE_SIMULATE_MSECS;
1480 }1475 }
1481 double timeSinceLastUpdate = (double)_lastTimeUpdated.nsecsElapsed() / 1000000.0;1476 double timeSinceLastUpdate = (double)_lastTimeUpdated.nsecsElapsed() / 1000000.0;
1482 if (timeSinceLastUpdate > targetFramePeriod) {1477 if (timeSinceLastUpdate > targetFramePeriod) {
@@ -3176,7 +3171,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 1693 unmodified lines
3176 } else {3171 } else {
3177 // if not rendering the billboard, the region is in device independent coordinates; must convert to device3172 // if not rendering the billboard, the region is in device independent coordinates; must convert to device
3178 QSize size = getTextureCache()->getFrameBufferSize();3173 QSize size = getTextureCache()->getFrameBufferSize();
3179 float ratio = QApplication::desktop()->windowHandle()->devicePixelRatio() * _renderResolutionScale;3174 float ratio = QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale();
3180 int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio;3175 int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio;
3181 glViewport(x, size.height() - y - height, width, height);3176 glViewport(x, size.height() - y - height, width, height);
3182 glScissor(x, size.height() - y - height, width, height);3177 glScissor(x, size.height() - y - height, width, height);
@@ -4234,13 +4229,11 @@ void Application::takeSnapshot() { · 1051 unmodified lines
4234 _snapshotShareDialog->show();4229 _snapshotShareDialog->show();
4235}4230}
4236 4231
4237void Application::setRenderTargetFramerate(unsigned int framerate, bool vsyncOn) {4232void Application::setVSyncEnabled(bool vsyncOn) {
4238 if (vsyncOn != _isVSyncOn) {
4239#if defined(Q_OS_WIN)4233#if defined(Q_OS_WIN)
4240 if (wglewGetExtension("WGL_EXT_swap_control")) {4234 if (wglewGetExtension("WGL_EXT_swap_control")) {
4241 wglSwapIntervalEXT(vsyncOn);4235 wglSwapIntervalEXT(vsyncOn);
4242 int swapInterval = wglGetSwapIntervalEXT();4236 int swapInterval = wglGetSwapIntervalEXT();
4243 _isVSyncOn = swapInterval;
4244 qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));4237 qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
4245 } else {4238 } else {
4246 qDebug("V-Sync is FORCED ON on this system\n");4239 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
4260#else4253#else
4261 qDebug("V-Sync is FORCED ON on this system\n");4254 qDebug("V-Sync is FORCED ON on this system\n");
4262#endif4255#endif
4256}
4257
4258bool 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;
4263 }4265 }
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
4265}4279}
4266 4280
4267bool Application::isVSyncEditable() {4281bool Application::isVSyncEditable() const {
4268#if defined(Q_OS_WIN)4282#if defined(Q_OS_WIN)
4269 if (wglewGetExtension("WGL_EXT_swap_control")) {4283 if (wglewGetExtension("WGL_EXT_swap_control")) {
4270 return true;4284 return true;
@@ -4281,6 +4295,43 @@ bool Application::isVSyncEditable() { · 10 unmodified lines
4281 return false;4295 return false;
4282}4296}
4283 4297
4284void Application::setRenderResolutionScale(float scale) {4298unsigned int Application::getRenderTargetFramerate() const {
4285 _renderResolutionScale = scale;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;
4286}4315}
4316
4317float 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