Changeset 2710 for code/trunk/src/orxonox/gamestates/GSGraphics.cc
- Timestamp:
- Feb 28, 2009, 7:46:37 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore deleted
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/gamestates/GSGraphics.cc
r2662 r2710 31 31 32 32 #include <fstream> 33 #include <boost/filesystem.hpp> 34 33 35 #include <OgreCompositorManager.h> 34 36 #include <OgreConfigFile.h> … … 43 45 #include <OgreWindowEventUtilities.h> 44 46 47 #include "SpecialConfig.h" 45 48 #include "util/Debug.h" 46 49 #include "util/Exception.h" 50 #include "util/String.h" 51 #include "util/SubString.h" 47 52 #include "core/ConsoleCommand.h" 48 53 #include "core/ConfigValueIncludes.h" … … 57 62 #include "gui/GUIManager.h" 58 63 #include "tools/WindowEventListener.h" 59 #include "Settings.h"60 64 61 65 // for compatibility … … 92 96 SetConfigValue(ogreConfigFile_, "ogre.cfg") 93 97 .description("Location of the Ogre config file"); 94 SetConfigValue(ogrePluginsFile_, "plugins.cfg") 95 .description("Location of the Ogre plugins file"); 98 SetConfigValue(ogrePluginsFolder_, ORXONOX_OGRE_PLUGINS_FOLDER) 99 .description("Folder where the Ogre plugins are located."); 100 SetConfigValue(ogrePlugins_, ORXONOX_OGRE_PLUGINS) 101 .description("Comma separated list of all plugins to load."); 96 102 SetConfigValue(ogreLogFile_, "ogre.log") 97 103 .description("Logfile for messages from Ogre. Use \"\" to suppress log file creation."); … … 102 108 SetConfigValue(ogreLogLevelCritical_, 2) 103 109 .description("Corresponding orxonox debug level for ogre Critical"); 104 SetConfigValue(defaultMasterKeybindings_, "def_masterKeybindings.ini")105 .description("Filename of default master keybindings.");106 110 } 107 111 … … 115 119 // Ogre setup procedure 116 120 setupOgre(); 121 // load all the required plugins for Ogre 122 loadOgrePlugins(); 123 // read resource declaration file 117 124 this->declareResources(); 118 this->loadRenderer(); // creates the render window 125 // Reads ogre config and creates the render window 126 this->loadRenderer(); 127 119 128 // TODO: Spread this so that this call only initialises things needed for the Console and GUI 120 129 this->initialiseResources(); … … 127 136 // load debug overlay 128 137 COUT(3) << "Loading Debug Overlay..." << std::endl; 129 this->debugOverlay_ = new XMLFile( Settings::getDataPath() + "overlay/debug.oxo");138 this->debugOverlay_ = new XMLFile((Core::getMediaPath() / "overlay" / "debug.oxo").file_string()); 130 139 Loader::open(debugOverlay_); 131 140 … … 138 147 // Configure master input state with a KeyBinder 139 148 masterKeyBinder_ = new KeyBinder(); 140 masterKeyBinder_->loadBindings("masterKeybindings.ini" , defaultMasterKeybindings_);149 masterKeyBinder_->loadBindings("masterKeybindings.ini"); 141 150 inputManager_->getMasterInputState()->addKeyHandler(masterKeyBinder_); 142 151 … … 200 209 delete this->ogreRoot_; 201 210 202 //#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32203 211 // delete the ogre log and the logManager (since we have created it). 204 212 this->ogreLogger_->getDefaultLog()->removeListener(this); 205 213 this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog()); 206 214 delete this->ogreLogger_; 207 //#endif208 215 209 216 delete graphicsEngine_; … … 276 283 COUT(3) << "Setting up Ogre..." << std::endl; 277 284 278 // TODO: LogManager doesn't work on oli platform. The why is yet unknown. 279 //#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 285 if (ogreConfigFile_ == "") 286 { 287 COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl; 288 ModifyConfigValue(ogreConfigFile_, tset, "config.cfg"); 289 } 290 if (ogreLogFile_ == "") 291 { 292 COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl; 293 ModifyConfigValue(ogreLogFile_, tset, "ogre.log"); 294 } 295 296 boost::filesystem::path ogreConfigFilepath(Core::getConfigPath() / this->ogreConfigFile_); 297 boost::filesystem::path ogreLogFilepath(Core::getLogPath() / this->ogreLogFile_); 298 280 299 // create a new logManager 300 // Ogre::Root will detect that we've already created a Log 281 301 ogreLogger_ = new Ogre::LogManager(); 282 302 COUT(4) << "Ogre LogManager created" << std::endl; … … 284 304 // create our own log that we can listen to 285 305 Ogre::Log *myLog; 286 if (this->ogreLogFile_ == "") 287 myLog = ogreLogger_->createLog("ogre.log", true, false, true); 288 else 289 myLog = ogreLogger_->createLog(this->ogreLogFile_, true, false, false); 306 myLog = ogreLogger_->createLog(ogreLogFilepath.file_string(), true, false, false); 290 307 COUT(4) << "Ogre Log created" << std::endl; 291 308 292 309 myLog->setLogDetail(Ogre::LL_BOREME); 293 310 myLog->addListener(this); 294 //#endif 295 296 // Root will detect that we've already created a Log 311 297 312 COUT(4) << "Creating Ogre Root..." << std::endl; 298 313 299 if (ogrePluginsFile_ == "")300 {301 COUT(2) << "Warning: Ogre plugins file set to \"\". Defaulting to plugins.cfg" << std::endl;302 ModifyConfigValue(ogrePluginsFile_, tset, "plugins.cfg");303 }304 if (ogreConfigFile_ == "")305 {306 COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;307 ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");308 }309 if (ogreLogFile_ == "")310 {311 COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;312 ModifyConfigValue(ogreLogFile_, tset, "ogre.log");313 }314 315 314 // check for config file existence because Ogre displays (caught) exceptions if not 316 std::ifstream probe; 317 probe.open(ogreConfigFile_.c_str()); 318 if (!probe) 315 if (!boost::filesystem::exists(ogreConfigFilepath)) 319 316 { 320 317 // create a zero sized file 321 318 std::ofstream creator; 322 creator.open(ogreConfigFile _.c_str());319 creator.open(ogreConfigFilepath.file_string().c_str()); 323 320 creator.close(); 324 321 } 325 else 326 probe.close(); 327 328 ogreRoot_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_); 329 330 #if 0 // Ogre 1.4.3 doesn't yet support setDebugOutputEnabled(.) 331 #if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32 332 // tame the ogre ouput so we don't get all the mess in the console 333 Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog(); 334 defaultLog->setDebugOutputEnabled(false); 335 defaultLog->setLogDetail(Ogre::LL_BOREME); 336 defaultLog->addListener(this); 337 #endif 338 #endif 322 323 // Leave plugins file empty. We're going to do that part manually later 324 ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.file_string(), ogreLogFilepath.file_string()); 339 325 340 326 COUT(3) << "Ogre set up done." << std::endl; 327 } 328 329 void GSGraphics::loadOgrePlugins() 330 { 331 // just to make sure the next statement doesn't segfault 332 if (ogrePluginsFolder_ == "") 333 ogrePluginsFolder_ = "."; 334 335 boost::filesystem::path folder(ogrePluginsFolder_); 336 // Do some SubString magic to get the comma separated list of plugins 337 SubString plugins(ogrePlugins_, ",", " ", false, 92, false, 34, false, 40, 41, false, '\0'); 338 for (unsigned int i = 0; i < plugins.size(); ++i) 339 ogreRoot_->loadPlugin((folder / plugins[i]).file_string()); 341 340 } 342 341 … … 357 356 try 358 357 { 359 cf.load( Settings::getDataPath() + resourceFile_);358 cf.load((Core::getMediaPath() / resourceFile_).file_string()); 360 359 } 361 360 catch (...) … … 383 382 384 383 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( 385 std::string(Settings::getDataPath() + archName), typeName, secName);384 (Core::getMediaPath() / archName).directory_string(), typeName, secName); 386 385 } 387 386 }
Note: See TracChangeset
for help on using the changeset viewer.