Changeset 7989 for code/branches
- Timestamp:
- Feb 27, 2011, 5:08:13 PM (14 years ago)
- Location:
- code/branches/usability/src/libraries/core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/usability/src/libraries/core/GraphicsManager.cc
r7966 r7989 49 49 #include "SpecialConfig.h" 50 50 #include "util/Clock.h" 51 #include "util/Convert.h" 51 52 #include "util/Exception.h" 52 53 #include "util/StringUtils.h" … … 68 69 namespace orxonox 69 70 { 71 static const std::string __CC_GraphicsManager_group = "GraphicsManager"; 72 static const std::string __CC_setScreenResolution_name = "setScreenResolution"; 73 static const std::string __CC_setFSAA_name = "setFSAA"; 74 static const std::string __CC_setVSync_name = "setVSync"; 75 DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name, &prototype::string__uint_uint_bool); 76 DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name, &prototype::string__string); 77 DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name, &prototype::string__bool); 78 70 79 static const std::string __CC_printScreen_name = "printScreen"; 71 80 DeclareConsoleCommand(__CC_printScreen_name, &prototype::void__void); … … 138 147 Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_.get()); 139 148 ModifyConsoleCommand(__CC_printScreen_name).resetFunction(); 149 ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name).resetFunction(); 150 ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name).resetFunction(); 151 ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name).resetFunction(); 140 152 141 153 // Undeclare the resources … … 332 344 // add console commands 333 345 ModifyConsoleCommand(__CC_printScreen_name).setFunction(&GraphicsManager::printScreen, this); 346 ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name).setFunction(&GraphicsManager::setScreenResolution, this); 347 ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name).setFunction(&GraphicsManager::setFSAA, this); 348 ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name).setFunction(&GraphicsManager::setVSync, this); 334 349 } 335 350 … … 463 478 } 464 479 480 std::string GraphicsManager::setScreenResolution(unsigned int width, unsigned int height, bool fullscreen) 481 { 482 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"); 483 this->ogreRoot_->getRenderSystem()->setConfigOption("Full Screen", fullscreen ? "Yes" : "No"); 484 485 std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions(); 486 487 if (validate == "") 488 { 489 GraphicsManager::getInstance().getRenderWindow()->setFullscreen(fullscreen, width, height); 490 this->ogreRoot_->saveConfig(); 491 Core::getInstance().updateOgreConfigTimestamp(); 492 } 493 494 return validate; 495 } 496 497 std::string GraphicsManager::setFSAA(const std::string& mode) 498 { 499 this->ogreRoot_->getRenderSystem()->setConfigOption("FSAA", mode); 500 501 std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions(); 502 503 if (validate == "") 504 { 505 //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_ 506 this->ogreRoot_->saveConfig(); 507 Core::getInstance().updateOgreConfigTimestamp(); 508 } 509 510 return validate; 511 } 512 513 std::string GraphicsManager::setVSync(bool vsync) 514 { 515 this->ogreRoot_->getRenderSystem()->setConfigOption("VSync", vsync ? "Yes" : "No"); 516 517 std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions(); 518 519 if (validate == "") 520 { 521 //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_ 522 this->ogreRoot_->saveConfig(); 523 Core::getInstance().updateOgreConfigTimestamp(); 524 } 525 526 return validate; 527 } 528 465 529 void GraphicsManager::printScreen() 466 530 { -
code/branches/usability/src/libraries/core/GraphicsManager.h
r7401 r7989 96 96 // console commands 97 97 void printScreen(); 98 std::string setScreenResolution(unsigned int width, unsigned int height, bool fullscreen); 99 std::string setFSAA(const std::string& mode); 100 std::string setVSync(bool vsync); 98 101 99 102 scoped_ptr<OgreWindowEventListener> ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h -
code/branches/usability/src/libraries/core/command/ConsoleCommand.h
r7861 r7989 317 317 inline void void__void(void) {} 318 318 inline void void__string(const std::string&) {} 319 320 inline std::string string__bool(bool) { return ""; } 321 inline std::string string__string(const std::string&) { return ""; } 322 inline std::string string__uint_uint_bool(unsigned int, unsigned int, bool) { return ""; } 319 323 } 320 324
Note: See TracChangeset
for help on using the changeset viewer.