Changeset 1024 for code/trunk/src/orxonox/GraphicsEngine.cc
- Timestamp:
- Apr 10, 2008, 5:35:49 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/GraphicsEngine.cc
r1021 r1024 35 35 #include <OgreException.h> 36 36 #include <OgreConfigFile.h> 37 #include <OgreLogManager.h> 37 38 #include <OgreTextureManager.h> 38 39 #include <OgreRenderWindow.h> … … 62 63 GraphicsEngine::~GraphicsEngine() 63 64 { 64 if ( !this->root_)65 if (this->root_) 65 66 delete this->root_; 67 // delete the ogre log and the logManager (sine we have created it). 68 if (LogManager::getSingletonPtr() != 0) 69 { 70 LogManager::getSingleton().getDefaultLog()->removeListener(this); 71 LogManager::getSingleton().destroyLog(LogManager::getSingleton().getDefaultLog()); 72 delete LogManager::getSingletonPtr(); 73 } 66 74 } 67 75 68 76 void GraphicsEngine::setConfigValues() 69 77 { 70 SetConfigValue(dataPath_, dataPath_).description("relative path to media data"); 71 72 } 73 78 SetConfigValue(dataPath_, "../../media/").description("relative path to media data"); 79 SetConfigValue(ogreLogfile_, "ogre.log").description("Logfile for messages from Ogre. Use \"\" to suppress log file creation."); 80 SetConfigValue(ogreLogLevelTrivial_ , 5).description("relative path to media data"); 81 SetConfigValue(ogreLogLevelNormal_ , 4).description("relative path to media data"); 82 SetConfigValue(ogreLogLevelCritical_, 2).description("relative path to media data"); 83 } 84 85 /** 86 @brief Creates the Ogre Root object and sets up the ogre log. 87 */ 74 88 void GraphicsEngine::setup() 75 89 { … … 86 100 std::string plugin_filename = "plugins.cfg"; 87 101 #endif 102 103 // create a logManager 104 LogManager *logger; 105 if(LogManager::getSingletonPtr() == 0) 106 logger = new LogManager(); 107 else 108 logger = LogManager::getSingletonPtr(); 109 110 // create our own log that we can listen to 111 Log *myLog; 112 if (this->ogreLogfile_ == "") 113 myLog = logger->createLog("ogre.log", true, false, true); 114 else 115 myLog = logger->createLog(this->ogreLogfile_, true, false, false); 116 117 myLog->setLogDetail(LL_BOREME); 118 myLog->addListener(this); 119 120 // Root will detect that we've already created a Log 88 121 root_ = new Root(plugin_filename); 89 122 } … … 106 139 // temporary overwrite of dataPath, change ini file for permanent change 107 140 if( dataPath != "" ) 108 dataPath_ = dataPath ;141 dataPath_ = dataPath + "/"; 109 142 loadRessourceLocations(this->dataPath_); 110 143 if (!root_->restoreConfig() && !root_->showConfigDialog()) … … 196 229 } 197 230 231 /** 232 @brief Method called by the LogListener interface from Ogre. 233 We use it to capture Ogre log messages and handle it ourselves. 234 @param message The message to be logged 235 @param lml The message level the log is using 236 @param maskDebug If we are printing to the console or not 237 @param logName the name of this log (so you can have several listeners 238 for different logs, and identify them) 239 */ 240 void GraphicsEngine::messageLogged(const std::string& message, 241 LogMessageLevel lml, bool maskDebug, const std::string &logName) 242 { 243 int orxonoxLevel; 244 switch (lml) 245 { 246 case LML_TRIVIAL: 247 orxonoxLevel = this->ogreLogLevelTrivial_; 248 break; 249 case LML_NORMAL: 250 orxonoxLevel = this->ogreLogLevelNormal_; 251 break; 252 case LML_CRITICAL: 253 orxonoxLevel = this->ogreLogLevelCritical_; 254 break; 255 default: 256 orxonoxLevel = 0; 257 } 258 OutputHandler::getOutStream().setOutputLevel(orxonoxLevel) 259 << "*** Ogre: " << message << std::endl; 260 } 198 261 }
Note: See TracChangeset
for help on using the changeset viewer.