[Orxonox-commit 3304] r7993 - code/branches/usability/src/libraries/core
landauf at orxonox.net
landauf at orxonox.net
Sun Feb 27 18:26:38 CET 2011
Author: landauf
Date: 2011-02-27 18:26:37 +0100 (Sun, 27 Feb 2011)
New Revision: 7993
Modified:
code/branches/usability/src/libraries/core/Game.cc
code/branches/usability/src/libraries/core/GraphicsManager.cc
code/branches/usability/src/libraries/core/GraphicsManager.h
Log:
moved fpsLimit_ config value to GraphicsSettings (seems more intuitive)
disabled fps limit if VSync is active (limits the fps anyway, but to the monitors refresh rate)
Modified: code/branches/usability/src/libraries/core/Game.cc
===================================================================
--- code/branches/usability/src/libraries/core/Game.cc 2011-02-27 17:01:32 UTC (rev 7992)
+++ code/branches/usability/src/libraries/core/Game.cc 2011-02-27 17:26:37 UTC (rev 7993)
@@ -49,6 +49,7 @@
#include "ConfigValueIncludes.h"
#include "GameMode.h"
#include "GameState.h"
+#include "GraphicsManager.h"
#include "GUIManager.h"
#include "command/ConsoleCommand.h"
@@ -141,7 +142,8 @@
.description("Sets the time in microseconds interval at which average fps, etc. get updated.");
SetConfigValue(statisticsAvgLength_, 1000000)
.description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
- SetConfigValue(fpsLimit_, 50)
+
+ SetConfigValueExternal(fpsLimit_, "GraphicsSettings", "fpsLimit", 50)
.description("Sets the desired frame rate (0 for no limit).");
}
@@ -206,7 +208,9 @@
this->updateStatistics();
// Limit frame rate
- this->updateFPSLimiter();
+ static bool hasVSync = GraphicsManager::getInstance().hasVSyncEnabled(); // can be static since changes of VSync currently require a restart
+ if (this->fpsLimit_ > 0 && !hasVSync)
+ this->updateFPSLimiter();
}
// UNLOAD all remaining states
Modified: code/branches/usability/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/branches/usability/src/libraries/core/GraphicsManager.cc 2011-02-27 17:01:32 UTC (rev 7992)
+++ code/branches/usability/src/libraries/core/GraphicsManager.cc 2011-02-27 17:26:37 UTC (rev 7993)
@@ -317,7 +317,11 @@
{
CCOUT(4) << "Configuring Renderer" << std::endl;
- if (!ogreRoot_->restoreConfig() || Core::getInstance().getOgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp())
+ bool updatedConfig = Core::getInstance().getOgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp();
+ if (updatedConfig)
+ COUT(2) << "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << std::endl;
+
+ if (!ogreRoot_->restoreConfig() || updatedConfig)
{
if (!ogreRoot_->showConfigDialog())
ThrowException(InitialisationFailed, "OGRE graphics configuration dialogue canceled.");
@@ -465,6 +469,15 @@
return this->renderWindow_->isFullScreen();
}
+ bool GraphicsManager::hasVSyncEnabled() const
+ {
+ Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions();
+ if (options.find("VSync") != options.end())
+ return (options["VSync"].currentValue == "Yes");
+ else
+ return false;
+ }
+
std::string GraphicsManager::setScreenResolution(unsigned int width, unsigned int height, bool fullscreen)
{
this->ogreRoot_->getRenderSystem()->setConfigOption("Video Mode", multi_cast<std::string>(width) + " x " + multi_cast<std::string>(height) + " @ " + multi_cast<std::string>(this->getRenderWindow()->getColourDepth()) + "-bit colour");
Modified: code/branches/usability/src/libraries/core/GraphicsManager.h
===================================================================
--- code/branches/usability/src/libraries/core/GraphicsManager.h 2011-02-27 17:01:32 UTC (rev 7992)
+++ code/branches/usability/src/libraries/core/GraphicsManager.h 2011-02-27 17:26:37 UTC (rev 7993)
@@ -74,6 +74,7 @@
Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
size_t getRenderWindowHandle();
bool isFullScreen() const;
+ bool hasVSyncEnabled() const;
void upgradeToGraphics();
void loadDebugOverlay();
More information about the Orxonox-commit
mailing list