[Orxonox-commit 3300] r7989 - in code/branches/usability/src/libraries/core: . command
landauf at orxonox.net
landauf at orxonox.net
Sun Feb 27 17:08:13 CET 2011
Author: landauf
Date: 2011-02-27 17:08:13 +0100 (Sun, 27 Feb 2011)
New Revision: 7989
Modified:
code/branches/usability/src/libraries/core/GraphicsManager.cc
code/branches/usability/src/libraries/core/GraphicsManager.h
code/branches/usability/src/libraries/core/command/ConsoleCommand.h
Log:
added console command to change screen resolution and fullscreen mode at runtime
added console commands to change FSAA and VSync (require restart)
Modified: code/branches/usability/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/branches/usability/src/libraries/core/GraphicsManager.cc 2011-02-27 11:48:50 UTC (rev 7988)
+++ code/branches/usability/src/libraries/core/GraphicsManager.cc 2011-02-27 16:08:13 UTC (rev 7989)
@@ -48,6 +48,7 @@
#include "SpecialConfig.h"
#include "util/Clock.h"
+#include "util/Convert.h"
#include "util/Exception.h"
#include "util/StringUtils.h"
#include "util/SubString.h"
@@ -67,6 +68,14 @@
namespace orxonox
{
+ static const std::string __CC_GraphicsManager_group = "GraphicsManager";
+ static const std::string __CC_setScreenResolution_name = "setScreenResolution";
+ static const std::string __CC_setFSAA_name = "setFSAA";
+ static const std::string __CC_setVSync_name = "setVSync";
+ DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name, &prototype::string__uint_uint_bool);
+ DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name, &prototype::string__string);
+ DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name, &prototype::string__bool);
+
static const std::string __CC_printScreen_name = "printScreen";
DeclareConsoleCommand(__CC_printScreen_name, &prototype::void__void);
@@ -137,6 +146,9 @@
Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_.get());
ModifyConsoleCommand(__CC_printScreen_name).resetFunction();
+ ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name).resetFunction();
+ ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name).resetFunction();
+ ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name).resetFunction();
// Undeclare the resources
Loader::unload(resources_.get());
@@ -331,6 +343,9 @@
// add console commands
ModifyConsoleCommand(__CC_printScreen_name).setFunction(&GraphicsManager::printScreen, this);
+ ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name).setFunction(&GraphicsManager::setScreenResolution, this);
+ ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name).setFunction(&GraphicsManager::setFSAA, this);
+ ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name).setFunction(&GraphicsManager::setVSync, this);
}
void GraphicsManager::loadDebugOverlay()
@@ -462,6 +477,55 @@
}
}
+ 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");
+ this->ogreRoot_->getRenderSystem()->setConfigOption("Full Screen", fullscreen ? "Yes" : "No");
+
+ std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions();
+
+ if (validate == "")
+ {
+ GraphicsManager::getInstance().getRenderWindow()->setFullscreen(fullscreen, width, height);
+ this->ogreRoot_->saveConfig();
+ Core::getInstance().updateOgreConfigTimestamp();
+ }
+
+ return validate;
+ }
+
+ std::string GraphicsManager::setFSAA(const std::string& mode)
+ {
+ this->ogreRoot_->getRenderSystem()->setConfigOption("FSAA", mode);
+
+ std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions();
+
+ if (validate == "")
+ {
+ //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_
+ this->ogreRoot_->saveConfig();
+ Core::getInstance().updateOgreConfigTimestamp();
+ }
+
+ return validate;
+ }
+
+ std::string GraphicsManager::setVSync(bool vsync)
+ {
+ this->ogreRoot_->getRenderSystem()->setConfigOption("VSync", vsync ? "Yes" : "No");
+
+ std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions();
+
+ if (validate == "")
+ {
+ //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_
+ this->ogreRoot_->saveConfig();
+ Core::getInstance().updateOgreConfigTimestamp();
+ }
+
+ return validate;
+ }
+
void GraphicsManager::printScreen()
{
assert(this->renderWindow_);
Modified: code/branches/usability/src/libraries/core/GraphicsManager.h
===================================================================
--- code/branches/usability/src/libraries/core/GraphicsManager.h 2011-02-27 11:48:50 UTC (rev 7988)
+++ code/branches/usability/src/libraries/core/GraphicsManager.h 2011-02-27 16:08:13 UTC (rev 7989)
@@ -95,6 +95,9 @@
// console commands
void printScreen();
+ std::string setScreenResolution(unsigned int width, unsigned int height, bool fullscreen);
+ std::string setFSAA(const std::string& mode);
+ std::string setVSync(bool vsync);
scoped_ptr<OgreWindowEventListener> ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h
#if OGRE_VERSION < 0x010600
Modified: code/branches/usability/src/libraries/core/command/ConsoleCommand.h
===================================================================
--- code/branches/usability/src/libraries/core/command/ConsoleCommand.h 2011-02-27 11:48:50 UTC (rev 7988)
+++ code/branches/usability/src/libraries/core/command/ConsoleCommand.h 2011-02-27 16:08:13 UTC (rev 7989)
@@ -316,6 +316,10 @@
{
inline void void__void(void) {}
inline void void__string(const std::string&) {}
+
+ inline std::string string__bool(bool) { return ""; }
+ inline std::string string__string(const std::string&) { return ""; }
+ inline std::string string__uint_uint_bool(unsigned int, unsigned int, bool) { return ""; }
}
namespace AccessLevel
More information about the Orxonox-commit
mailing list