Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 6, 2008, 7:39:38 PM (16 years ago)
Author:
rgrieder
Message:

Moved all Ogre related code from GSRoot to GSGraphics.
You should now be able to start the gui, goto ioConsole, then start the gui again and load the level.
gui —> level —> gui doesn't yet work. But I will not dig into that until our object hierarchy has been replaced.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r1826 r1891  
    3030#include "GSRoot.h"
    3131
    32 #include <OgreLogManager.h>
    33 #include <OgreRoot.h>
    34 
    3532#include "util/Exception.h"
    3633#include "util/Debug.h"
    3734#include "core/Factory.h"
    38 #include "core/ConfigFileManager.h"
    3935#include "core/ConfigValueIncludes.h"
    4036#include "core/CoreIncludes.h"
     
    7167        : RootGameState("root")
    7268        , settings_(0)
    73         , ogreRoot_(0)
    74         , ogreLogger_(0)
    75         , graphicsEngine_(0)
    7669        , tclBind_(0)
    7770        , tclThreadManager_(0)
     
    7972    {
    8073        RegisterRootObject(GSRoot);
     74        setConfigValues();
    8175    }
    8276
     
    8781    void GSRoot::setConfigValues()
    8882    {
    89         SetConfigValue(ogreConfigFile_,  "ogre.cfg").description("Location of the Ogre config file");
    90         SetConfigValue(ogrePluginsFile_, "plugins.cfg").description("Location of the Ogre plugins file");
    91         SetConfigValue(ogreLogFile_,     "ogre.log").description("Logfile for messages from Ogre. \
    92                                                                  Use \"\" to suppress log file creation.");
    93         SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial");
    94         SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
    95         SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
    9683    }
    9784
    9885    void GSRoot::enter()
    9986    {
    100 #if ORXONOX_DEBUG_MODE == 1
    101         ConfigFileManager::getInstance().setFile(CFT_Settings, "orxonox_d.ini");
    102 #else
    103         ConfigFileManager::getInstance().setFile(CFT_Settings, "orxonox.ini");
    104 #endif
    105 
    106         // do this after the previous call..
    107         setConfigValues();
    108 
    10987        // creates the class hierarchy for all classes with factories
    11088        Factory::createClassHierarchy();
     
    130108        this->shell_ = new Shell();
    131109
    132         setupOgre();
    133 
    134         // initialise graphics engine. Doesn't load the render window yet!
    135         graphicsEngine_ = new GraphicsEngine();
    136 
    137110        // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
    138111        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
     
    157130    {
    158131        // TODO: remove and destroy console commands
    159 
    160         delete graphicsEngine_;
    161 
    162         delete this->ogreRoot_;
    163 
    164 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    165         // delete the ogre log and the logManager (since we have created it).
    166         this->ogreLogger_->getDefaultLog()->removeListener(this);
    167         this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
    168         delete this->ogreLogger_;
    169 #endif
    170132
    171133        delete this->shell_;
     
    203165            DWORD procMask;
    204166            DWORD sysMask;
    205 #if _MSC_VER >= 1400 && defined (_M_X64)
     167#  if _MSC_VER >= 1400 && defined (_M_X64)
    206168            GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
    207 #else
     169#  else
    208170            GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
    209 #endif
     171#  endif
    210172
    211173            // If procMask is 0, consider there is only one core available
     
    227189#endif
    228190    }
    229 
    230     /**
    231     @brief
    232         Creates the Ogre Root object and sets up the ogre log.
    233     */
    234     void GSRoot::setupOgre()
    235     {
    236         COUT(3) << "Setting up Ogre..." << std::endl;
    237 
    238         // TODO: LogManager doesn't work on oli platform. The why is yet unknown.
    239 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    240         // create a new logManager
    241         ogreLogger_ = new Ogre::LogManager();
    242         COUT(4) << "Ogre LogManager created" << std::endl;
    243 
    244         // create our own log that we can listen to
    245         Ogre::Log *myLog;
    246         if (this->ogreLogFile_ == "")
    247             myLog = ogreLogger_->createLog("ogre.log", true, false, true);
    248         else
    249             myLog = ogreLogger_->createLog(this->ogreLogFile_, true, false, false);
    250         COUT(4) << "Ogre Log created" << std::endl;
    251 
    252         myLog->setLogDetail(Ogre::LL_BOREME);
    253         myLog->addListener(this);
    254 #endif
    255 
    256         // Root will detect that we've already created a Log
    257         COUT(4) << "Creating Ogre Root..." << std::endl;
    258 
    259         if (ogrePluginsFile_ == "")
    260         {
    261             COUT(2) << "Warning: Ogre plugins file set to \"\". Defaulting to plugins.cfg" << std::endl;
    262             ModifyConfigValue(ogrePluginsFile_, tset, "plugins.cfg");
    263         }
    264         if (ogreConfigFile_ == "")
    265         {
    266             COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
    267             ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
    268         }
    269         if (ogreLogFile_ == "")
    270         {
    271             COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
    272             ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
    273         }
    274 
    275         // check for config file existence because Ogre displays (caught) exceptions if not
    276         std::ifstream probe;
    277         probe.open(ogreConfigFile_.c_str());
    278         if (!probe)
    279         {
    280             // create a zero sized file
    281             std::ofstream creator;
    282             creator.open(ogreConfigFile_.c_str());
    283             creator.close();
    284         }
    285         else
    286             probe.close();
    287 
    288         ogreRoot_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_);
    289 
    290 #if 0 // Ogre 1.4.3 doesn't yet support setDebugOutputEnabled(.)
    291 #if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
    292         // tame the ogre ouput so we don't get all the mess in the console
    293         Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog();
    294         defaultLog->setDebugOutputEnabled(false);
    295         defaultLog->setLogDetail(Ogre::LL_BOREME);
    296         defaultLog->addListener(this);
    297 #endif
    298 #endif
    299 
    300         COUT(3) << "Ogre set up done." << std::endl;
    301     }
    302 
    303     /**
    304     @brief
    305         Method called by the LogListener interface from Ogre.
    306         We use it to capture Ogre log messages and handle it ourselves.
    307     @param message
    308         The message to be logged
    309     @param lml
    310         The message level the log is using
    311     @param maskDebug
    312         If we are printing to the console or not
    313     @param logName
    314         The name of this log (so you can have several listeners
    315         for different logs, and identify them)
    316     */
    317     void GSRoot::messageLogged(const std::string& message,
    318         Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName)
    319     {
    320         int orxonoxLevel;
    321         switch (lml)
    322         {
    323         case Ogre::LML_TRIVIAL:
    324             orxonoxLevel = this->ogreLogLevelTrivial_;
    325             break;
    326         case Ogre::LML_NORMAL:
    327             orxonoxLevel = this->ogreLogLevelNormal_;
    328             break;
    329         case Ogre::LML_CRITICAL:
    330             orxonoxLevel = this->ogreLogLevelCritical_;
    331             break;
    332         default:
    333             orxonoxLevel = 0;
    334         }
    335         OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
    336             << "Ogre: " << message << std::endl;
    337     }
    338191}
Note: See TracChangeset for help on using the changeset viewer.