Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 10, 2008, 5:35:49 PM (16 years ago)
Author:
rgrieder
Message:

merged input back into trunk
note: I have created an asylum with obsolete code, please check the files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/GraphicsEngine.cc

    r1021 r1024  
    3535#include <OgreException.h>
    3636#include <OgreConfigFile.h>
     37#include <OgreLogManager.h>
    3738#include <OgreTextureManager.h>
    3839#include <OgreRenderWindow.h>
     
    6263  GraphicsEngine::~GraphicsEngine()
    6364  {
    64     if (!this->root_)
     65    if (this->root_)
    6566      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    }
    6674  }
    6775
    6876  void GraphicsEngine::setConfigValues()
    6977  {
    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  */
    7488  void GraphicsEngine::setup()
    7589  {
     
    86100    std::string plugin_filename = "plugins.cfg";
    87101#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
    88121    root_ = new Root(plugin_filename);
    89122  }
     
    106139    // temporary overwrite of dataPath, change ini file for permanent change
    107140    if( dataPath != "" )
    108       dataPath_ = dataPath;
     141      dataPath_ = dataPath + "/";
    109142    loadRessourceLocations(this->dataPath_);
    110143    if (!root_->restoreConfig() && !root_->showConfigDialog())
     
    196229  }
    197230
     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  }
    198261}
Note: See TracChangeset for help on using the changeset viewer.