Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 28, 2009, 7:46:37 PM (15 years ago)
Author:
rgrieder
Message:

Merged buildsystem3 containing buildsystem2 containing Adi's buildsystem branch back to the trunk.
Please update the media directory if you were not using buildsystem3 before.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/gamestates/GSGraphics.cc

    r2662 r2710  
    3131
    3232#include <fstream>
     33#include <boost/filesystem.hpp>
     34
    3335#include <OgreCompositorManager.h>
    3436#include <OgreConfigFile.h>
     
    4345#include <OgreWindowEventUtilities.h>
    4446
     47#include "SpecialConfig.h"
    4548#include "util/Debug.h"
    4649#include "util/Exception.h"
     50#include "util/String.h"
     51#include "util/SubString.h"
    4752#include "core/ConsoleCommand.h"
    4853#include "core/ConfigValueIncludes.h"
     
    5762#include "gui/GUIManager.h"
    5863#include "tools/WindowEventListener.h"
    59 #include "Settings.h"
    6064
    6165// for compatibility
     
    9296        SetConfigValue(ogreConfigFile_,  "ogre.cfg")
    9397            .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.");
    96102        SetConfigValue(ogreLogFile_,     "ogre.log")
    97103            .description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
     
    102108        SetConfigValue(ogreLogLevelCritical_, 2)
    103109            .description("Corresponding orxonox debug level for ogre Critical");
    104         SetConfigValue(defaultMasterKeybindings_, "def_masterKeybindings.ini")
    105             .description("Filename of default master keybindings.");
    106110    }
    107111
     
    115119        // Ogre setup procedure
    116120        setupOgre();
     121        // load all the required plugins for Ogre
     122        loadOgrePlugins();
     123        // read resource declaration file
    117124        this->declareResources();
    118         this->loadRenderer();    // creates the render window
     125        // Reads ogre config and creates the render window
     126        this->loadRenderer();
     127
    119128        // TODO: Spread this so that this call only initialises things needed for the Console and GUI
    120129        this->initialiseResources();
     
    127136        // load debug overlay
    128137        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());
    130139        Loader::open(debugOverlay_);
    131140
     
    138147        // Configure master input state with a KeyBinder
    139148        masterKeyBinder_ = new KeyBinder();
    140         masterKeyBinder_->loadBindings("masterKeybindings.ini", defaultMasterKeybindings_);
     149        masterKeyBinder_->loadBindings("masterKeybindings.ini");
    141150        inputManager_->getMasterInputState()->addKeyHandler(masterKeyBinder_);
    142151
     
    200209        delete this->ogreRoot_;
    201210
    202 //#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    203211        // delete the ogre log and the logManager (since we have created it).
    204212        this->ogreLogger_->getDefaultLog()->removeListener(this);
    205213        this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
    206214        delete this->ogreLogger_;
    207 //#endif
    208215
    209216        delete graphicsEngine_;
     
    276283        COUT(3) << "Setting up Ogre..." << std::endl;
    277284
    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
    280299        // create a new logManager
     300        // Ogre::Root will detect that we've already created a Log
    281301        ogreLogger_ = new Ogre::LogManager();
    282302        COUT(4) << "Ogre LogManager created" << std::endl;
     
    284304        // create our own log that we can listen to
    285305        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);
    290307        COUT(4) << "Ogre Log created" << std::endl;
    291308
    292309        myLog->setLogDetail(Ogre::LL_BOREME);
    293310        myLog->addListener(this);
    294 //#endif
    295 
    296         // Root will detect that we've already created a Log
     311
    297312        COUT(4) << "Creating Ogre Root..." << std::endl;
    298313
    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 
    315314        // 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))
    319316        {
    320317            // create a zero sized file
    321318            std::ofstream creator;
    322             creator.open(ogreConfigFile_.c_str());
     319            creator.open(ogreConfigFilepath.file_string().c_str());
    323320            creator.close();
    324321        }
    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());
    339325
    340326        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());
    341340    }
    342341
     
    357356        try
    358357        {
    359             cf.load(Settings::getDataPath() + resourceFile_);
     358            cf.load((Core::getMediaPath() / resourceFile_).file_string());
    360359        }
    361360        catch (...)
     
    383382
    384383                    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
    385                         std::string(Settings::getDataPath() + archName), typeName, secName);
     384                        (Core::getMediaPath() / archName).directory_string(), typeName, secName);
    386385                }
    387386            }
Note: See TracChangeset for help on using the changeset viewer.