Index: code/branches/gui/src/orxonox/GraphicsEngine.cc
===================================================================
--- code/branches/gui/src/orxonox/GraphicsEngine.cc	(revision 1674)
+++ code/branches/gui/src/orxonox/GraphicsEngine.cc	(revision 1686)
@@ -37,32 +37,15 @@
 #include "GraphicsEngine.h"
 
-#include <fstream>
-
-#include <OgreConfigFile.h>
-#include <OgreException.h>
-#include <OgreLogManager.h>
-#include <OgreRoot.h>
-#include <OgreSceneManager.h>
-#include <OgreTextureManager.h>
-#include <OgreViewport.h>
+#include <OgreRenderWindow.h>
 
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
 #include "core/Debug.h"
-#include "core/CommandExecutor.h"
-#include "core/ConsoleCommand.h"
-#include "core/Exception.h"
 
-#include "overlays/console/InGameConsole.h"
-#include "overlays/OverlayGroup.h"
 #include "tools/ParticleInterface.h"
-#include "Settings.h"
-#include "tools/WindowEventListener.h"
-
-#include "objects/CameraHandler.h"
 
 namespace orxonox
 {
-    SetConsoleCommand(GraphicsEngine, printScreen, true).setKeybindMode(KeybindMode::OnPress);
+    //SetConsoleCommand(GraphicsEngine, printScreen, true).setKeybindMode(KeybindMode::OnPress);
 
     GraphicsEngine* GraphicsEngine::singletonRef_s = 0;
@@ -103,13 +86,4 @@
     void GraphicsEngine::setConfigValues()
     {
-        SetConfigValue(resourceFile_,    "resources.cfg").description("Location of the resources file in the data path.");
-        SetConfigValue(ogreConfigFile_,  "ogre.cfg").description("Location of the Ogre config file");
-        SetConfigValue(ogrePluginsFile_, "plugins.cfg").description("Location of the Ogre plugins file");
-        SetConfigValue(ogreLogFile_,     "ogre.log").description("Logfile for messages from Ogre. \
-                                                                 Use \"\" to suppress log file creation.");
-        SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial");
-        SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
-        SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
-
         unsigned int old = this->detailLevelParticle_;
         SetConfigValue(detailLevelParticle_, 2).description("O: off, 1: low, 2: normal, 3: high");
@@ -126,231 +100,5 @@
     GraphicsEngine::~GraphicsEngine()
     {
-        CCOUT(4) << "Destroying objects..." << std::endl;
-        Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this);
-        if (this->root_)
-            delete this->root_;
-
-#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
-        // delete the ogre log and the logManager (since we have created it).
-        if (Ogre::LogManager::getSingletonPtr() != 0)
-        {
-            Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this);
-            Ogre::LogManager::getSingleton().destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
-            delete Ogre::LogManager::getSingletonPtr();
-        }
-        CCOUT(4) << "Destroying objects done" << std::endl;
-#endif
-
         singletonRef_s = 0;
-    }
-
-    /**
-    @brief
-        Creates the Ogre Root object and sets up the ogre log.
-    */
-    void GraphicsEngine::setup()
-    {
-        CCOUT(3) << "Setting up..." << std::endl;
-
-        // TODO: LogManager doesn't work on oli platform. The why is yet unknown.
-#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
-        // create a new logManager
-        Ogre::LogManager* logger = new Ogre::LogManager();
-        CCOUT(4) << "Ogre LogManager created" << std::endl;
-
-        // create our own log that we can listen to
-        Ogre::Log *myLog;
-        if (this->ogreLogFile_ == "")
-            myLog = logger->createLog("ogre.log", true, false, true);
-        else
-            myLog = logger->createLog(this->ogreLogFile_, true, false, false);
-        CCOUT(4) << "Ogre Log created" << std::endl;
-
-        myLog->setLogDetail(Ogre::LL_BOREME);
-        myLog->addListener(this);
-#endif
-
-        // Root will detect that we've already created a Log
-        CCOUT(4) << "Creating Ogre Root..." << std::endl;
-
-        if (ogrePluginsFile_ == "")
-        {
-            COUT(2) << "Warning: Ogre plugins file set to \"\". Defaulting to plugins.cfg" << std::endl;
-            ModifyConfigValue(ogrePluginsFile_, tset, "plugins.cfg");
-        }
-        if (ogreConfigFile_ == "")
-        {
-            COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
-            ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
-        }
-        if (ogreLogFile_ == "")
-        {
-            COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
-            ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
-        }
-
-        root_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_);
-
-        // We don't need plugins for the dedicated..
-        //if (!root_->getInstalledPlugins().size() > 0)
-        //{
-        //    ThrowException(PluginsNotFound, "No Ogre plugins declared. Cannot load Ogre.");
-        //}
-
-#if 0 // Ogre 1.4.3 doesn't yet support setDebugOutputEnabled(.)
-#if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
-        // tame the ogre ouput so we don't get all the mess in the console
-        Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog();
-        defaultLog->setDebugOutputEnabled(false);
-        defaultLog->setLogDetail(Ogre::LL_BOREME);
-        defaultLog->addListener(this);
-#endif
-#endif
-
-        CCOUT(4) << "Creating Ogre Root done" << std::endl;
-
-        // specify where Ogre has to look for resources. This call doesn't parse anything yet!
-        declareRessourceLocations();
-
-        CCOUT(3) << "Set up done." << std::endl;
-    }
-
-    void GraphicsEngine::declareRessourceLocations()
-    {
-        CCOUT(4) << "Declaring Resources" << std::endl;
-        //TODO: Specify layout of data file and maybe use xml-loader
-        //TODO: Work with ressource groups (should be generated by a special loader)
-
-        if (resourceFile_ == "")
-        {
-            COUT(2) << "Warning: Ogre resource file set to \"\". Defaulting to resources.cfg" << std::endl;
-            ModifyConfigValue(resourceFile_, tset, "resources.cfg");
-        }
-
-        // Load resource paths from data file using configfile ressource type
-        Ogre::ConfigFile cf;
-        try
-        {
-            cf.load(Settings::getDataPath() + resourceFile_);
-        }
-        catch (...)
-        {
-            //COUT(1) << ex.getFullDescription() << std::endl;
-            COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl;
-            throw;
-        }
-
-        // Go through all sections & settings in the file
-        Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
-
-        std::string secName, typeName, archName;
-        while (seci.hasMoreElements())
-        {
-            try
-            {
-                secName = seci.peekNextKey();
-                Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
-                Ogre::ConfigFile::SettingsMultiMap::iterator i;
-                for (i = settings->begin(); i != settings->end(); ++i)
-                {
-                    typeName = i->first; // for instance "FileSystem" or "Zip"
-                    archName = i->second; // name (and location) of archive
-
-                    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
-                        std::string(Settings::getDataPath() + archName), typeName, secName);
-                }
-            }
-            catch (Ogre::Exception& ex)
-            {
-                COUT(1) << ex.getFullDescription() << std::endl;
-            }
-        }
-    }
-
-    void GraphicsEngine::loadRenderer()
-    {
-        CCOUT(4) << "Configuring Renderer" << std::endl;
-
-        // check for file existence because Ogre displays exceptions if not
-        std::ifstream probe;
-        probe.open(ogreConfigFile_.c_str());
-        if (!probe)
-        {
-            // create a zero sized file
-            std::ofstream creator;
-            creator.open(ogreConfigFile_.c_str());
-            creator.close();
-        }
-        else
-            probe.close();
-
-        if (!root_->restoreConfig())
-            if (!root_->showConfigDialog())
-                ThrowException(InitialisationFailed, "Could not show Ogre configuration dialogue.");
-
-        CCOUT(4) << "Creating render window" << std::endl;
-
-        this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
-
-        Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
-
-        //Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
-
-        // create a full screen default viewport
-        this->viewport_ = this->renderWindow_->addViewport(0, 0);
-    }
-
-    void GraphicsEngine::initialiseResources()
-    {
-        CCOUT(4) << "Initialising resources" << std::endl;
-        //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
-        try
-        {
-            Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
-            /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
-            for (unsigned int i = 0; i < str.size(); i++)
-            {
-            Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]);
-            }*/
-        }
-        catch (...)
-        {
-            CCOUT(2) << "Error: There was a serious error when initialising the resources." << std::endl;
-            throw;
-        }
-    }
-
-    /**
-    @brief
-        Creates the SceneManager
-    */
-    void GraphicsEngine::createNewScene()
-    {
-        CCOUT(4) << "Creating new SceneManager..." << std::endl;
-        if (levelSceneManager_)
-        {
-            CCOUT(2) << "SceneManager already exists! Skipping." << std::endl;
-        }
-        this->levelSceneManager_ = this->root_->createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
-        CCOUT(3) << "Created SceneManager: " << levelSceneManager_->getName() << std::endl;
-    }
-
-    /**
-    @brief
-        Returns the window handle of the render window.
-        At least the InputHandler uses this to create the OIS::InputManager
-    @return
-        The window handle of the render window
-    */
-    size_t GraphicsEngine::getWindowHandle()
-    {
-        if (this->renderWindow_)
-        {
-            size_t windowHnd = 0;
-            this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd);
-            return windowHnd;
-        }
-        else
-            return 0;
     }
 
@@ -396,99 +144,3 @@
             return 1.0f;
     }
-
-    /**
-    @brief
-        Method called by the LogListener interface from Ogre.
-        We use it to capture Ogre log messages and handle it ourselves.
-    @param message
-        The message to be logged
-    @param lml
-        The message level the log is using
-    @param maskDebug
-        If we are printing to the console or not
-    @param logName
-        The name of this log (so you can have several listeners
-        for different logs, and identify them)
-    */
-    void GraphicsEngine::messageLogged(const std::string& message,
-        Ogre::LogMessageLevel lml, bool maskDebug, const std::string &logName)
-    {
-        int orxonoxLevel;
-        switch (lml)
-        {
-        case Ogre::LML_TRIVIAL:
-            orxonoxLevel = this->ogreLogLevelTrivial_;
-            break;
-        case Ogre::LML_NORMAL:
-            orxonoxLevel = this->ogreLogLevelNormal_;
-            break;
-        case Ogre::LML_CRITICAL:
-            orxonoxLevel = this->ogreLogLevelCritical_;
-            break;
-        default:
-            orxonoxLevel = 0;
-        }
-        OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
-            << "Ogre: " << message << std::endl;
-    }
-
-    /**
-    @brief
-        Window has moved.
-    @param rw
-        The render window it occured in
-    */
-    void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw)
-    {
-        for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)
-            it->windowMoved();
-    }
-
-    /**
-    @brief
-        Window has resized.
-    @param rw
-        The render window it occured in
-    @note
-        GraphicsEngine has a render window stored itself. This is the same
-        as rw. But we have to be careful when using multiple render windows!
-    */
-    void GraphicsEngine::windowResized(Ogre::RenderWindow *rw)
-    {
-        for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)
-            it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
-    }
-
-    /**
-    @brief
-        Window focus has changed.
-    @param rw
-        The render window it occured in
-    */
-    void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw)
-    {
-        for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)
-            it->windowFocusChanged();
-    }
-
-    /**
-    @brief
-        Window was closed.
-    @param rw
-        The render window it occured in
-    */
-    void GraphicsEngine::windowClosed(Ogre::RenderWindow *rw)
-    {
-        // using CommandExecutor in order to avoid depending on Orxonox.h.
-        CommandExecutor::execute("exit", false);
-    }
-
-
-    /*static*/ void GraphicsEngine::printScreen()
-    {
-        if (getInstance().renderWindow_)
-        {
-            getInstance().renderWindow_->writeContentsToTimestampedFile("shot_", ".jpg");
-        }
-    }
 }
Index: code/branches/gui/src/orxonox/GraphicsEngine.h
===================================================================
--- code/branches/gui/src/orxonox/GraphicsEngine.h	(revision 1674)
+++ code/branches/gui/src/orxonox/GraphicsEngine.h	(revision 1686)
@@ -42,7 +42,4 @@
 
 #include <OgrePrerequisites.h>
-#include <OgreLog.h>
-#include <OgreRenderWindow.h>
-#include <OgreWindowEventUtilities.h>
 #include "core/OrxonoxClass.h"
 
@@ -52,6 +49,9 @@
     @brief Graphics engine manager class
     */
-    class _OrxonoxExport GraphicsEngine : public Ogre::WindowEventListener, public Ogre::LogListener, public OrxonoxClass
+    class _OrxonoxExport GraphicsEngine : public OrxonoxClass
     {
+        // HACK: temporary means
+        friend class GSGraphics;
+
     public:
         GraphicsEngine();
@@ -59,9 +59,4 @@
 
         void setConfigValues();
-        void setup();
-        void declareRessourceLocations();
-        void loadRenderer();
-        void initialiseResources();
-        void createNewScene();
 
         void setLevelSceneManager(Ogre::SceneManager* sceneMgr) { this->levelSceneManager_ = sceneMgr; }
@@ -69,8 +64,7 @@
 
         Ogre::Viewport* getViewport() { return this->viewport_; }
+        Ogre::Root*     getOgreRoot() { return this->root_; }
 
         // several window properties
-        Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
-        size_t getWindowHandle();
         int getWindowWidth() const;
         int getWindowHeight() const;
@@ -81,12 +75,6 @@
         void setAverageFramesPerSecond(float fps) { this->avgFramesPerSecond_ = fps; }
 
-        void setWindowActivity(bool activity)
-        { if (this->renderWindow_) this->renderWindow_->setActive(activity); }
-
         inline unsigned int getDetailLevelParticle() const
         { return this->detailLevelParticle_; }
-
-        // console commands
-        static void printScreen();
 
         static GraphicsEngine& getInstance();
@@ -95,15 +83,5 @@
     private:
         // don't mess with singletons
-        GraphicsEngine(GraphicsEngine&) { }
-
-        //! Method called by the LogListener from Ogre
-        void messageLogged(const std::string&, Ogre::LogMessageLevel,
-            bool, const std::string&);
-
-        // window events from Ogre::WindowEventListener
-        void windowMoved       (Ogre::RenderWindow* rw);
-        void windowResized     (Ogre::RenderWindow* rw);
-        void windowFocusChanged(Ogre::RenderWindow* rw);
-        void windowClosed      (Ogre::RenderWindow* rw);
+        GraphicsEngine(GraphicsEngine&);
 
         Ogre::Root*         root_;                  //!< Ogre's root
@@ -117,11 +95,4 @@
 
         // config values
-        std::string         resourceFile_;          //!< resources file name
-        std::string         ogreConfigFile_;        //!< ogre config file name
-        std::string         ogrePluginsFile_;       //!< ogre plugins file name
-        std::string         ogreLogFile_;           //!< log file name for Ogre log messages
-        int                 ogreLogLevelTrivial_;   //!< Corresponding Orxonx debug level for LL_TRIVIAL
-        int                 ogreLogLevelNormal_;    //!< Corresponding Orxonx debug level for LL_NORMAL
-        int                 ogreLogLevelCritical_;  //!< Corresponding Orxonx debug level for LL_CRITICAL
         unsigned int        detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
 
Index: code/branches/gui/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/gui/src/orxonox/Orxonox.cc	(revision 1674)
+++ 	(revision )
@@ -1,494 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- @file
- @brief Orxonox Main Class
- */
-
-// Precompiled Headers
-#include "OrxonoxStableHeaders.h"
-#include "Orxonox.h"
-
-//****** STD *******
-#include <deque>
-#include <cassert>
-
-//****** OGRE ******
-#include <OgreFrameListener.h>
-#include <OgreRoot.h>
-#include <OgreTimer.h>
-#include <OgreWindowEventUtilities.h>
-
-//***** ORXONOX ****
-// util
-//#include "util/Sleep.h"
-
-// core
-#include "core/ConfigFileManager.h"
-#include "core/ConfigValueIncludes.h"
-#include "core/ConsoleCommand.h"
-#include "core/Debug.h"
-#include "core/Loader.h"
-#include "core/Exception.h"
-#include "core/input/InputManager.h"
-#include "core/input/SimpleInputState.h"
-#include "core/input/KeyBinder.h"
-#include "core/TclBind.h"
-#include "core/Core.h"
-
-// audio
-#include "audio/AudioManager.h"
-
-// network
-#include "network/Server.h"
-#include "network/Client.h"
-
-// objects and tools
-#include "overlays/console/InGameConsole.h"
-#include "objects/Tickable.h"
-#include "objects/Backlight.h"
-#include "tools/ParticleInterface.h"
-#include "gui/GUIManager.h"
-
-#include "GraphicsEngine.h"
-#include "Settings.h"
-#include "Radar.h"
-
-// globals for the server or client
-static network::Client *client_g = 0;
-static network::Server *server_g = 0;
-
-namespace orxonox
-{
-  //SetConsoleCommand(Orxonox, exit, true).setKeybindMode(KeybindMode::OnPress);
-  //SetConsoleCommand(Orxonox, slomo, true).setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0).setAxisParamIndex(0).setIsAxisRelative(false);
-  //SetConsoleCommand(Orxonox, setTimeFactor, true).setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0);
-  //SetConsoleCommand(Orxonox, loadGame, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, "standalone");
-
-  /**
-    @brief Reference to the only instance of the class.
-  */
-  Orxonox *Orxonox::singletonRef_s = 0;
-
-  /**
-   * Create a new instance of Orxonox. Avoid doing any actual work here.
-   */
-  Orxonox::Orxonox()
-    : startLevel_(0)
-    , hud_(0)
-    //, auMan_(0)
-    , timer_(0)
-    , bAbort_(false)
-    , timefactor_(1.0f)
-    , debugRefreshTime_(0.0f)
-    , graphicsEngine_(0)
-    , inputManager_(0)
-    , radar_(0)
-    , console_(0)
-    , guiManager_(0)
-  {
-    RegisterRootObject(Orxonox);
-
-    //assert(singletonRef_s == 0);
-    OrxAssert(singletonRef_s == 0, "Cannot instantiate Orxonox class twice");
-    singletonRef_s = this;
-  }
-
-  /**
-   * Destruct Orxonox.
-   */
-  Orxonox::~Orxonox()
-  {
-    // keep in mind: the order of deletion is very important!
-    if (this->timer_)
-      delete this->timer_;
-
-    Loader::unload(startLevel_);
-    if (this->startLevel_)
-      delete this->startLevel_;
-
-    Loader::unload(hud_);
-    if (this->hud_)
-      delete this->hud_;
-
-    if (this->radar_)
-      delete this->radar_;
-
-    if (this->guiManager_)
-      delete guiManager_;
-
-    //if (this->auMan_)
-    //  delete this->auMan_;
-
-    if (this->console_)
-      delete this->console_;
-
-    if (inputManager_)
-      delete inputManager_;
-
-    if (this->graphicsEngine_)
-      delete graphicsEngine_;
-
-    if (network::Client::getSingleton())
-      network::Client::destroySingleton();
-    if (server_g)
-      delete network::Server::getSingleton();
-
-    // this call will delete every BaseObject!
-    // But currently this will call methods of objects that exist no more
-    // The only 'memory leak' is the ParticleSpawer. They would be deleted here
-    // and call a sceneNode method that has already been destroy by the corresponding space ship.
-    //Loader::close();
-
-    singletonRef_s = 0;
-  }
-
-  void Orxonox::setConfigValues()
-  {
-    SetConfigValue(debugRefreshTime_, 0.2).description("Sets the time interval at which average fps, etc. get updated.");
-  }
-
-
-  /**
-    Asks the mainloop nicely to abort.
-  */
-  void Orxonox::abortRequest()
-  {
-    COUT(3) << "Orxonox: Abort requested." << std::endl;
-    bAbort_ = true;
-  }
-
-  /**
-   * @return singleton reference
-   */
-  Orxonox& Orxonox::getInstance()
-  {
-    assert(singletonRef_s);
-    return *singletonRef_s;
-  }
-
-  /**
-    @brief Changes the speed of Orxonox
-  */
-  void Orxonox::setTimeFactor(float factor)
-  {
-    float change = factor / Orxonox::getInstance().getTimeFactor();
-    Orxonox::getInstance().timefactor_ = factor;
-    for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it)
-        it->setSpeedFactor(it->getSpeedFactor() * change);
-
-    for (Iterator<Backlight> it = ObjectList<Backlight>::begin(); it; ++it)
-        it->setTimeFactor(Orxonox::getInstance().getTimeFactor());
-  }
-
-    /**
-    @brief
-        Starts the whole Game.
-    @param path
-        path to config (in home dir or something)
-    */
-    void Orxonox::start()
-    {
-#if ORXONOX_DEBUG_MODE == 1
-        ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox_d.ini");
-#else
-        ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
-#endif
-
-        // creates the class hierarchy for all classes with factories
-        Factory::createClassHierarchy();
-
-        setConfigValues();
-
-        //const Settings::CommandLineArgument* dataPath = Settings::getCommandLineArgument("dataPath");
-        //assert(dataPath);
-        //if (!dataPath->bHasDefaultValue_)
-        //{
-        //    if (*dataPath->value_.getString().end() != '/' && *dataPath->value_.getString().end() != '\\')
-        //        Settings::tsetDataPath(dataPath->value_.getString() + "/");
-        //    else
-        //        Settings::tsetDataPath(dataPath->value_.getString());
-        //}
-
-        try
-        {
-            // initialise TCL
-            TclBind::getInstance().setDataPath(Settings::getDataPath());
-
-            graphicsEngine_ = new GraphicsEngine();
-            graphicsEngine_->setup();       // creates ogre root and other essentials
-
-            if (Settings::showsGraphics())
-            {
-                graphicsEngine_->loadRenderer();    // creates the render window
-
-                // TODO: Spread this so that this call only initialises things needed for the Console and GUI
-                graphicsEngine_->initialiseResources();
-
-                // Calls the InputManager which sets up the input devices.
-                // The render window width and height are used to set up the mouse movement.
-                inputManager_ = new InputManager();
-                inputManager_->initialise(graphicsEngine_->getWindowHandle(),
-                    graphicsEngine_->getWindowWidth(), graphicsEngine_->getWindowHeight(), true);
-                KeyBinder* keyBinder = new KeyBinder();
-                keyBinder->loadBindings();
-                inputManager_->createInputState<SimpleInputState>("game", 20)->setHandler(keyBinder);
-
-                // Load the InGameConsole
-                console_ = new InGameConsole();
-                console_->initialise();
-
-                // load the CEGUI interface
-                guiManager_ = new GUIManager();
-                guiManager_->initialise();
-            }
-            else
-            {
-                // TODO: Initialise a not yet written console that operates in the shell we
-                // started the game from.
-                // We probably want to use std::cin to catch input (OIS uses DirectX or X server)
-            }
-        }
-        catch (std::exception& ex)
-        {
-            COUT(1) << ex.what() << std::endl;
-            COUT(1) << "Loading sequence aborted." << std::endl;
-            return;
-        }
-
-        // here happens the game
-        startRenderLoop();
-
-        //if (mode_.mode == GameMode::Client)
-        //    network::Client::getSingleton()->closeConnection();
-
-        //if (mode_.hasServer)
-        //    server_g->close();
-    }
-
-  /**
-   * Loads everything in the scene except for the actual objects.
-   * This includes HUD, audio..
-   */
-  bool Orxonox::loadPlayground()
-  {
-    // Start the Radar
-    this->radar_ = new Radar();
-
-    // Load the HUD
-    COUT(3) << "Orxonox: Loading HUD" << std::endl;
-    hud_ = new Level(Settings::getDataPath() + "overlay/hud.oxo");
-    return Loader::load(hud_);
-  }
-
-  /**
-   * Helper method to load a level.
-   */
-  bool Orxonox::loadScene()
-  {
-    COUT(0) << "Loading level..." << std::endl;
-    startLevel_ = new Level(Settings::getDataPath() + "levels/sample.oxw");
-    return Loader::open(startLevel_);
-  }
-
-  /**
-   * Level loading method for server mode.
-   */
-  bool Orxonox::serverLoad()
-  {
-    COUT(0) << "Loading level in server mode" << std::endl;
-
-    //assert(Settings::getCommandLineArgument("port"));
-    //int serverPort = Settings::getCommandLineArgument("port")->value_;
-    ////server_g = new network::Server(serverPort_);
-    //server_g = network::Server::createSingleton(serverPort);
-
-    if (!loadScene())
-      return false;
-
-    server_g->open();
-
-    return true;
-  }
-
-  /**
-   * Level loading method for client mode.
-   */
-  bool Orxonox::clientLoad()
-  {
-    COUT(0) << "Loading level in client mode" << std::endl;\
-
-    //assert(Settings::getCommandLineArgument("port"));
-    //assert(Settings::getCommandLineArgument("ip"));
-    //int serverPort = Settings::getCommandLineArgument("port")->value_;
-    //std::string serverIP = Settings::getCommandLineArgument("ip")->value_;
-
-    //if (serverIP.compare("") == 0)
-    //  client_g = network::Client::createSingleton();
-    //else
-    //  client_g = network::Client::createSingleton(serverIP, serverPort);
-
-    if(!client_g->establishConnection())
-      return false;
-    client_g->tick(0);
-
-    return true;
-  }
-
-  /**
-   * Level loading method for standalone mode.
-   */
-  bool Orxonox::standaloneLoad()
-  {
-    COUT(0) << "Loading level in standalone mode" << std::endl;
-
-    if (!loadScene())
-      return false;
-
-    return true;
-  }
-
-  /**
-    Main loop of the orxonox game.
-    We use the Ogre::Timer to measure time since it uses the most precise
-    method an a platform (however the windows timer lacks time when under
-    heavy kernel load!).
-    There is a simple mechanism to measure the average time spent in our
-    ticks as it may indicate performance issues.
-    A note about the Ogre::FrameListener: Even though we don't use them,
-    they still get called. However, the delta times are not correct (except
-    for timeSinceLastFrame, which is the most important). A little research
-    as shown that there is probably only one FrameListener that doesn't even
-    need the time. So we shouldn't run into problems.
-  */
-  void Orxonox::startRenderLoop()
-  {
-    Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
-
-    // use the ogre timer class to measure time.
-    if (!timer_)
-      timer_ = new Ogre::Timer();
-
-    unsigned long frameCount = 0;
-    
-    const unsigned long refreshTime = (unsigned long)(debugRefreshTime_ * 1000000.0f);
-    unsigned long refreshStartTime = 0;
-    unsigned long tickTime = 0;
-    unsigned long oldFrameCount = 0;
-
-    unsigned long timeBeforeTick = 0;
-    unsigned long timeBeforeTickOld = 0;
-    unsigned long timeAfterTick = 0;
-
-    // TODO: Update time in seconds every 7 seconds to avoid any overflow (7 secs is very tight)
-
-    COUT(3) << "Orxonox: Starting the main loop." << std::endl;
-
-    try
-    {
-    timer_->reset();
-    while (!bAbort_)
-    {
-        // get current time
-        timeBeforeTickOld = timeBeforeTick;
-        timeBeforeTick    = timer_->getMicroseconds();
-        float dt = (timeBeforeTick - timeBeforeTickOld) / 1000000.0;
-
-
-        // tick the core (needs real time for input and tcl thread management)
-        //Core::tick(dt);
-
-        // Call those objects that need the real time
-        for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
-          it->tick(dt);
-        // Call the scene objects
-        for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
-          it->tick(dt * this->timefactor_);
-
-        // call server/client with normal dt
-        if (client_g)
-          client_g->tick(dt * this->timefactor_);
-        if (server_g)
-          server_g->tick(dt * this->timefactor_);
-
-
-        // get current time once again
-        timeAfterTick = timer_->getMicroseconds();
-
-        tickTime += timeAfterTick - timeBeforeTick;
-        if (timeAfterTick > refreshStartTime + refreshTime)
-        {
-          GraphicsEngine::getInstance().setAverageTickTime(
-              (float)tickTime * 0.001 / (frameCount - oldFrameCount));
-          float avgFPS = (float)(frameCount - oldFrameCount) / (timeAfterTick - refreshStartTime) * 1000000.0;
-          GraphicsEngine::getInstance().setAverageFramesPerSecond(avgFPS);
-
-          oldFrameCount = frameCount;
-          tickTime = 0;
-          refreshStartTime = timeAfterTick;
-        }
-
-        // don't forget to call _fireFrameStarted in ogre to make sure
-        // everything goes smoothly
-        Ogre::FrameEvent evt;
-        evt.timeSinceLastFrame = dt;
-        evt.timeSinceLastEvent = dt; // note: same time, but shouldn't matter anyway
-        ogreRoot._fireFrameStarted(evt);
-
-        if (Settings::showsGraphics())
-        {
-          // Pump messages in all registered RenderWindows
-          // This calls the WindowEventListener objects.
-          Ogre::WindowEventUtilities::messagePump();
-          // make sure the window stays active even when not focused
-          // (probably only necessary on windows)
-          GraphicsEngine::getInstance().setWindowActivity(true);
-
-          // tick CEGUI
-          GUIManager::getInstance().tick(dt);
-
-          // render
-          ogreRoot._updateAllRenderTargets();
-        }
-
-        // again, just to be sure ogre works fine
-        ogreRoot._fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
-
-        ++frameCount;
-    }
-    }
-    catch (std::exception& ex)
-    {
-      // something went wrong.
-      COUT(1) << ex.what() << std::endl;
-      COUT(1) << "Main loop was stopped by an unhandled exception. Shutting down." << std::endl;
-    }
-  }
-}
Index: code/branches/gui/src/orxonox/Orxonox.h
===================================================================
--- code/branches/gui/src/orxonox/Orxonox.h	(revision 1674)
+++ 	(revision )
@@ -1,105 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- @file  Orxonox.h
- @brief Main Orxonox Class File
- @author Benjamin Knecht <beni_at_orxonox.net>
- */
-
-#ifndef _Orxonox_H__
-#define _Orxonox_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <string>
-
-#include <OgrePrerequisites.h>
-
-#include "core/OrxonoxClass.h"
-#include "audio/AudioPrereqs.h"
-#include "GraphicsEngine.h"
-#include "Settings.h"
-
-namespace orxonox
-{
-  //! Orxonox singleton class
-    class _OrxonoxExport Orxonox : public OrxonoxClass
-  {
-    public:
-      Orxonox();
-      ~Orxonox();
-
-      void start();
-      void setConfigValues();
-
-      void abortRequest();
-
-      static Orxonox& getInstance();
-
-      static void slomo(float factor) { Orxonox::setTimeFactor(factor); }
-      static float getTimeFactor()    { return Orxonox::getInstance().timefactor_; }
-      static void loadGame(const std::string& name);
-      static void exit()              { Orxonox::getInstance().abortRequest(); }
-      static void setTimeFactor(float factor = 1.0);
-
-   private:
-      // don't mess with singletons
-      Orxonox(Orxonox& instance);
-
-      bool serverLoad();
-      bool clientLoad();
-      bool standaloneLoad();
-
-      bool loadPlayground();
-      bool loadScene();
-      void startRenderLoop();
-
-    private:
-      Level*                startLevel_;       //!< current hard coded default level
-      Level*                hud_;              //!< 'level' object fo the HUD
-      //audio::AudioManager*  auMan_;            //!< audio manager
-      Ogre::Timer*          timer_;            //!< Main loop timer
-      bool                  bAbort_;           //!< aborts the render loop if true
-      float                 timefactor_;       //!< A factor to change the gamespeed
-
-      // config values
-      float                 debugRefreshTime_;
-
-      // By Orxonox managed singleton pointers
-      GraphicsEngine*       graphicsEngine_;   //!< our dearest graphics engine <3
-      InputManager*         inputManager_;
-      Radar*                radar_;            //!< represents the Radar (not the HUD part)
-      InGameConsole*        console_;
-      GUIManager*           guiManager_;
-
-      static Orxonox *singletonRef_s;
-  };
-}
-#endif /* _Orxonox_H__ */
Index: code/branches/gui/src/orxonox/gamestates/GSGUI.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSGUI.cc	(revision 1674)
+++ code/branches/gui/src/orxonox/gamestates/GSGUI.cc	(revision 1686)
@@ -30,4 +30,5 @@
 #include "GSGUI.h"
 
+#include <OgreViewport.h>
 #include "GraphicsEngine.h"
 #include "core/input/InputManager.h"
Index: code/branches/gui/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSGraphics.cc	(revision 1674)
+++ code/branches/gui/src/orxonox/gamestates/GSGraphics.cc	(revision 1686)
@@ -30,14 +30,26 @@
 #include "GSGraphics.h"
 
+#include <fstream>
+#include <OgreConfigFile.h>
 #include <OgreFrameListener.h>
 #include <OgreRoot.h>
+#include <OgreException.h>
+#include <OgreRenderWindow.h>
+#include <OgreTextureManager.h>
+#include <OgreViewport.h>
 #include <OgreWindowEventUtilities.h>
-#include <OgreRenderWindow.h>
-
+
+#include "core/Debug.h"
 #include "core/ConsoleCommand.h"
 #include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
 #include "core/input/InputManager.h"
+#include "core/Exception.h"
 #include "overlays/console/InGameConsole.h"
 #include "gui/GUIManager.h"
+#include "tools/WindowEventListener.h"
+#include "Settings.h"
+
+// for compatibility
 #include "GraphicsEngine.h"
 
@@ -47,5 +59,4 @@
         : GameState("graphics")
         , ogreRoot_(0)
-        , graphicsEngine_(0)
         , inputManager_(0)
         , console_(0)
@@ -57,4 +68,5 @@
         , tickTime_(0)
     {
+        RegisterRootObject(GSGraphics);
     }
 
@@ -65,4 +77,5 @@
     void GSGraphics::setConfigValues()
     {
+        SetConfigValue(resourceFile_,    "resources.cfg").description("Location of the resources file in the data path.");
         SetConfigValue(statisticsRefreshCycle_, 200000).description("Sets the time in microseconds interval at which average fps, etc. get updated.");
     }
@@ -73,16 +86,24 @@
 
         this->ogreRoot_ = Ogre::Root::getSingletonPtr();
-        this->graphicsEngine_ = GraphicsEngine::getInstancePtr();
-
-        graphicsEngine_->loadRenderer();    // creates the render window
-
+
+        this->declareResources();
+        this->loadRenderer();    // creates the render window
         // TODO: Spread this so that this call only initialises things needed for the Console and GUI
-        graphicsEngine_->initialiseResources();
+        this->initialiseResources();
+
+
+        // HACK: temporary:
+        GraphicsEngine& graphicsEngine = GraphicsEngine::getInstance();
+        graphicsEngine.renderWindow_ = this->renderWindow_;
+        graphicsEngine.root_ = this->ogreRoot_;
+        graphicsEngine.viewport_ = this->viewport_;
+
 
         // Calls the InputManager which sets up the input devices.
         // The render window width and height are used to set up the mouse movement.
         inputManager_ = new InputManager();
-        inputManager_->initialise(graphicsEngine_->getWindowHandle(),
-            graphicsEngine_->getWindowWidth(), graphicsEngine_->getWindowHeight(), true);
+        size_t windowHnd = 0;
+        this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd);
+        inputManager_->initialise(windowHnd, renderWindow_->getWidth(), renderWindow_->getHeight(), true);
 
         // Load the InGameConsole
@@ -92,5 +113,5 @@
         // load the CEGUI interface
         guiManager_ = new GUIManager();
-        guiManager_->initialise();
+        guiManager_->initialise(this->renderWindow_);
 
         // reset frame counter
@@ -99,4 +120,9 @@
         statisticsStartTime_ = 0;
         statisticsStartCount_ = 0;
+
+        // add console commands
+        FunctorMember<GSGraphics>* functor1 = createFunctor(&GSGraphics::printScreen);
+        functor1->setObject(this);
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "printScreen"));
     }
 
@@ -109,6 +135,6 @@
         delete this->inputManager_;
 
-        this->ogreRoot_->detachRenderTarget(GraphicsEngine::getInstance().getRenderWindow());
-        delete GraphicsEngine::getInstance().getRenderWindow();
+        this->ogreRoot_->detachRenderTarget(this->renderWindow_);
+        delete this->renderWindow_;
         //this->ogreRoot_->shutdown
         // TODO: destroy render window
@@ -166,5 +192,5 @@
         // make sure the window stays active even when not focused
         // (probably only necessary on windows)
-        GraphicsEngine::getInstance().setWindowActivity(true);
+        this->renderWindow_->setActive(true);
 
         // render
@@ -176,3 +202,156 @@
         ++frameCount_;
     }
+
+    void GSGraphics::declareResources()
+    {
+        CCOUT(4) << "Declaring Resources" << std::endl;
+        //TODO: Specify layout of data file and maybe use xml-loader
+        //TODO: Work with ressource groups (should be generated by a special loader)
+
+        if (resourceFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre resource file set to \"\". Defaulting to resources.cfg" << std::endl;
+            ModifyConfigValue(resourceFile_, tset, "resources.cfg");
+        }
+
+        // Load resource paths from data file using configfile ressource type
+        Ogre::ConfigFile cf;
+        try
+        {
+            cf.load(Settings::getDataPath() + resourceFile_);
+        }
+        catch (...)
+        {
+            //COUT(1) << ex.getFullDescription() << std::endl;
+            COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl;
+            throw;
+        }
+
+        // Go through all sections & settings in the file
+        Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
+
+        std::string secName, typeName, archName;
+        while (seci.hasMoreElements())
+        {
+            try
+            {
+                secName = seci.peekNextKey();
+                Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
+                Ogre::ConfigFile::SettingsMultiMap::iterator i;
+                for (i = settings->begin(); i != settings->end(); ++i)
+                {
+                    typeName = i->first; // for instance "FileSystem" or "Zip"
+                    archName = i->second; // name (and location) of archive
+
+                    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
+                        std::string(Settings::getDataPath() + archName), typeName, secName);
+                }
+            }
+            catch (Ogre::Exception& ex)
+            {
+                COUT(1) << ex.getFullDescription() << std::endl;
+            }
+        }
+    }
+
+    void GSGraphics::loadRenderer()
+    {
+        CCOUT(4) << "Configuring Renderer" << std::endl;
+
+        if (!ogreRoot_->restoreConfig())
+            if (!ogreRoot_->showConfigDialog())
+                ThrowException(InitialisationFailed, "Could not show Ogre configuration dialogue.");
+
+        CCOUT(4) << "Creating render window" << std::endl;
+
+        this->renderWindow_ = ogreRoot_->initialise(true, "OrxonoxV2");
+
+        Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
+
+        //Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
+
+        // create a full screen default viewport
+        this->viewport_ = this->renderWindow_->addViewport(0, 0);
+    }
+
+    void GSGraphics::initialiseResources()
+    {
+        CCOUT(4) << "Initialising resources" << std::endl;
+        //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
+        try
+        {
+            Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+            /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
+            for (unsigned int i = 0; i < str.size(); i++)
+            {
+            Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]);
+            }*/
+        }
+        catch (...)
+        {
+            CCOUT(2) << "Error: There was a serious error when initialising the resources." << std::endl;
+            throw;
+        }
+    }
+
+
+    /**
+    @brief
+        Window has moved.
+    @param rw
+        The render window it occured in
+    */
+    void GSGraphics::windowMoved(Ogre::RenderWindow *rw)
+    {
+        for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)
+            it->windowMoved();
+    }
+
+    /**
+    @brief
+        Window has resized.
+    @param rw
+        The render window it occured in
+    @note
+        GraphicsEngine has a render window stored itself. This is the same
+        as rw. But we have to be careful when using multiple render windows!
+    */
+    void GSGraphics::windowResized(Ogre::RenderWindow *rw)
+    {
+        for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)
+            it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
+    }
+
+    /**
+    @brief
+        Window focus has changed.
+    @param rw
+        The render window it occured in
+    */
+    void GSGraphics::windowFocusChanged(Ogre::RenderWindow *rw)
+    {
+        for (Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)
+            it->windowFocusChanged();
+    }
+
+    /**
+    @brief
+        Window was closed.
+    @param rw
+        The render window it occured in
+    */
+    void GSGraphics::windowClosed(Ogre::RenderWindow *rw)
+    {
+        // using CommandExecutor in order to avoid depending on Orxonox.h.
+        //CommandExecutor::execute("exit", false);
+        this->requestState("root");
+    }
+
+    void GSGraphics::printScreen()
+    {
+        if (this->renderWindow_)
+        {
+            this->renderWindow_->writeContentsToTimestampedFile("shot_", ".jpg");
+        }
+    }
 }
Index: code/branches/gui/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSGraphics.h	(revision 1674)
+++ code/branches/gui/src/orxonox/gamestates/GSGraphics.h	(revision 1686)
@@ -32,4 +32,5 @@
 #include "OrxonoxPrereqs.h"
 #include <OgrePrerequisites.h>
+#include <OgreWindowEventUtilities.h>
 #include "core/GameState.h"
 #include "core/OrxonoxClass.h"
@@ -37,11 +38,10 @@
 namespace orxonox
 {
-    class _OrxonoxExport GSGraphics : public GameState, public OrxonoxClass
+    class _OrxonoxExport GSGraphics : public GameState, public OrxonoxClass, public Ogre::WindowEventListener
     {
+        friend class ClassIdentifier<GSGraphics>;
     public:
         GSGraphics();
         ~GSGraphics();
-
-        void setConfigValues();
 
     private:
@@ -50,6 +50,23 @@
         void ticked(const Clock& time);
 
+        void setConfigValues();
+
+        void declareResources();
+        void loadRenderer();
+        void initialiseResources();
+
+        void printScreen();
+
+        // window events from Ogre::WindowEventListener
+        void windowMoved       (Ogre::RenderWindow* rw);
+        void windowResized     (Ogre::RenderWindow* rw);
+        void windowFocusChanged(Ogre::RenderWindow* rw);
+        void windowClosed      (Ogre::RenderWindow* rw);
+
         Ogre::Root*           ogreRoot_;
-        GraphicsEngine*       graphicsEngine_;   //!< pointer to GraphicsEngine instance
+        Ogre::RenderWindow*   renderWindow_;          //!< the current render window
+        Ogre::Viewport*       viewport_;              //!< default full size viewport
+
+        // managed singletons
         InputManager*         inputManager_;
         InGameConsole*        console_;
@@ -62,4 +79,8 @@
         unsigned long         statisticsStartCount_;
         unsigned int          tickTime_;
+
+        // config values
+        std::string           resourceFile_;          //!< resources file name
+        unsigned int          detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
     };
 }
Index: code/branches/gui/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSLevel.cc	(revision 1674)
+++ code/branches/gui/src/orxonox/gamestates/GSLevel.cc	(revision 1686)
@@ -30,4 +30,6 @@
 #include "GSLevel.h"
 
+#include <OgreSceneManager.h>
+#include <OgreRoot.h>
 #include "core/input/InputManager.h"
 #include "core/input/SimpleInputState.h"
@@ -45,4 +47,5 @@
         : GameState(name)
         , timeFactor_(1.0f)
+        , sceneManager_(0)
         , keyBinder_(0)
         , inputState_(0)
@@ -65,5 +68,8 @@
 
         // create Ogre SceneManager for the level
-        GraphicsEngine::getInstance().createNewScene();
+        this->sceneManager_ = GraphicsEngine::getInstance().getOgreRoot()->
+            createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
+        COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
+        GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
 
         // Start the Radar
@@ -92,5 +98,5 @@
         delete this->radar_;
 
-        // TODO: delete SceneManager
+        GraphicsEngine::getInstance().getOgreRoot()->destroySceneManager(this->sceneManager_);
 
         inputState_->setHandler(0);
Index: code/branches/gui/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSLevel.h	(revision 1674)
+++ code/branches/gui/src/orxonox/gamestates/GSLevel.h	(revision 1686)
@@ -31,4 +31,5 @@
 
 #include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
 #include "core/GameState.h"
 
@@ -58,4 +59,5 @@
         float timeFactor_;       //!< A factor to change the gamespeed
 
+        Ogre::SceneManager*   sceneManager_;
         KeyBinder*            keyBinder_;        //!< tool that loads and manages the input bindings
         SimpleInputState*     inputState_;
Index: code/branches/gui/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSRoot.cc	(revision 1674)
+++ code/branches/gui/src/orxonox/gamestates/GSRoot.cc	(revision 1686)
@@ -30,8 +30,12 @@
 #include "GSRoot.h"
 
+#include <OgreLogManager.h>
+#include <OgreRoot.h>
+
 //#include "util/SubString.h"
 #include "core/Factory.h"
 #include "core/ConfigFileManager.h"
 #include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
 #include "core/ConsoleCommand.h"
 #include "core/CommandLine.h"
@@ -65,10 +69,24 @@
         : RootGameState("root")
         , settings_(0)
+        , ogreRoot_(0)
+        , ogreLogger_(0)
         , graphicsEngine_(0)
     {
+        RegisterRootObject(GSRoot);
     }
 
     GSRoot::~GSRoot()
     {
+    }
+
+    void GSRoot::setConfigValues()
+    {
+        SetConfigValue(ogreConfigFile_,  "ogre.cfg").description("Location of the Ogre config file");
+        SetConfigValue(ogrePluginsFile_, "plugins.cfg").description("Location of the Ogre plugins file");
+        SetConfigValue(ogreLogFile_,     "ogre.log").description("Logfile for messages from Ogre. \
+                                                                 Use \"\" to suppress log file creation.");
+        SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial");
+        SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
+        SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
     }
 
@@ -108,4 +126,7 @@
 #endif
 
+        // do this after the previous call..
+        setConfigValues();
+
         // creates the class hierarchy for all classes with factories
         Factory::createClassHierarchy();
@@ -128,7 +149,8 @@
         TclThreadManager::getInstance();
 
+        setupOgre();
+
         // initialise graphics engine. Doesn't load the render window yet!
         graphicsEngine_ = new GraphicsEngine();
-        graphicsEngine_->setup();       // creates ogre root and other essentials
 
         // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
@@ -151,4 +173,14 @@
     {
         delete graphicsEngine_;
+
+        delete this->ogreRoot_;
+
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+        // delete the ogre log and the logManager (since we have created it).
+        this->ogreLogger_->getDefaultLog()->removeListener(this);
+        this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
+        delete this->ogreLogger_;
+#endif
+
         delete settings_;
 
@@ -199,3 +231,112 @@
 #endif
     }
+
+    /**
+    @brief
+        Creates the Ogre Root object and sets up the ogre log.
+    */
+    void GSRoot::setupOgre()
+    {
+        COUT(3) << "Setting up Ogre..." << std::endl;
+
+        // TODO: LogManager doesn't work on oli platform. The why is yet unknown.
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+        // create a new logManager
+        ogreLogger_ = new Ogre::LogManager();
+        COUT(4) << "Ogre LogManager created" << std::endl;
+
+        // create our own log that we can listen to
+        Ogre::Log *myLog;
+        if (this->ogreLogFile_ == "")
+            myLog = ogreLogger_->createLog("ogre.log", true, false, true);
+        else
+            myLog = ogreLogger_->createLog(this->ogreLogFile_, true, false, false);
+        COUT(4) << "Ogre Log created" << std::endl;
+
+        myLog->setLogDetail(Ogre::LL_BOREME);
+        myLog->addListener(this);
+#endif
+
+        // Root will detect that we've already created a Log
+        COUT(4) << "Creating Ogre Root..." << std::endl;
+
+        if (ogrePluginsFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre plugins file set to \"\". Defaulting to plugins.cfg" << std::endl;
+            ModifyConfigValue(ogrePluginsFile_, tset, "plugins.cfg");
+        }
+        if (ogreConfigFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
+            ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
+        }
+        if (ogreLogFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
+            ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
+        }
+
+        // check for config file existence because Ogre displays (caught) exceptions if not
+        std::ifstream probe;
+        probe.open(ogreConfigFile_.c_str());
+        if (!probe)
+        {
+            // create a zero sized file
+            std::ofstream creator;
+            creator.open(ogreConfigFile_.c_str());
+            creator.close();
+        }
+        else
+            probe.close();
+
+        ogreRoot_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_);
+
+#if 0 // Ogre 1.4.3 doesn't yet support setDebugOutputEnabled(.)
+#if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
+        // tame the ogre ouput so we don't get all the mess in the console
+        Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog();
+        defaultLog->setDebugOutputEnabled(false);
+        defaultLog->setLogDetail(Ogre::LL_BOREME);
+        defaultLog->addListener(this);
+#endif
+#endif
+
+        COUT(3) << "Ogre set up done." << std::endl;
+    }
+
+    /**
+    @brief
+        Method called by the LogListener interface from Ogre.
+        We use it to capture Ogre log messages and handle it ourselves.
+    @param message
+        The message to be logged
+    @param lml
+        The message level the log is using
+    @param maskDebug
+        If we are printing to the console or not
+    @param logName
+        The name of this log (so you can have several listeners
+        for different logs, and identify them)
+    */
+    void GSRoot::messageLogged(const std::string& message,
+        Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName)
+    {
+        int orxonoxLevel;
+        switch (lml)
+        {
+        case Ogre::LML_TRIVIAL:
+            orxonoxLevel = this->ogreLogLevelTrivial_;
+            break;
+        case Ogre::LML_NORMAL:
+            orxonoxLevel = this->ogreLogLevelNormal_;
+            break;
+        case Ogre::LML_CRITICAL:
+            orxonoxLevel = this->ogreLogLevelCritical_;
+            break;
+        default:
+            orxonoxLevel = 0;
+        }
+        OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
+            << "Ogre: " << message << std::endl;
+    }
 }
Index: code/branches/gui/src/orxonox/gamestates/GSRoot.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSRoot.h	(revision 1674)
+++ code/branches/gui/src/orxonox/gamestates/GSRoot.h	(revision 1686)
@@ -31,10 +31,13 @@
 
 #include "OrxonoxPrereqs.h"
+#include <OgreLog.h>
 #include "core/RootGameState.h"
+#include "core/OrxonoxClass.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSRoot : public RootGameState
+    class _OrxonoxExport GSRoot : public RootGameState, public Ogre::LogListener, public OrxonoxClass
     {
+        friend class ClassIdentifier<GSRoot>;
     public:
         GSRoot();
@@ -51,8 +54,21 @@
         void ticked(const Clock& time);
 
+        void setConfigValues();
+        void messageLogged(const std::string& message, Ogre::LogMessageLevel lml,
+            bool maskDebug, const std::string& logName);
         void setThreadAffinity();
+        void setupOgre();
 
         Settings*             settings_;
+        Ogre::Root*           ogreRoot_;                  //!< Ogre's root
+        Ogre::LogManager*     ogreLogger_;
         GraphicsEngine*       graphicsEngine_;   //!< Interface to Ogre
+
+        std::string           ogreConfigFile_;        //!< ogre config file name
+        std::string           ogrePluginsFile_;       //!< ogre plugins file name
+        std::string           ogreLogFile_;           //!< log file name for Ogre log messages
+        int                   ogreLogLevelTrivial_;   //!< Corresponding Orxonx debug level for LL_TRIVIAL
+        int                   ogreLogLevelNormal_;    //!< Corresponding Orxonx debug level for LL_NORMAL
+        int                   ogreLogLevelCritical_;  //!< Corresponding Orxonx debug level for LL_CRITICAL
     };
 }
Index: code/branches/gui/src/orxonox/gui/GUIManager.cc
===================================================================
--- code/branches/gui/src/orxonox/gui/GUIManager.cc	(revision 1674)
+++ code/branches/gui/src/orxonox/gui/GUIManager.cc	(revision 1686)
@@ -117,5 +117,5 @@
     }
 
-    bool GUIManager::initialise()
+    bool GUIManager::initialise(Ogre::RenderWindow* renderWindow)
     {
         using namespace CEGUI;
@@ -126,6 +126,6 @@
             try
             {
-                // get the render window
-                renderWindow_ = GraphicsEngine::getInstance().getRenderWindow();
+                // save the render window
+                renderWindow_ = renderWindow;
 
                 // Full screen viewport with Z order = 0 (top most). Don't yet feed a camera (so nothing gets rendered)
Index: code/branches/gui/src/orxonox/gui/GUIManager.h
===================================================================
--- code/branches/gui/src/orxonox/gui/GUIManager.h	(revision 1674)
+++ code/branches/gui/src/orxonox/gui/GUIManager.h	(revision 1686)
@@ -64,5 +64,5 @@
         ~GUIManager();
 
-        bool initialise();
+        bool initialise(Ogre::RenderWindow* renderWindow);
         void tick(float dt)
         {
Index: code/branches/gui/src/orxonox/objects/Backlight.cc
===================================================================
--- code/branches/gui/src/orxonox/objects/Backlight.cc	(revision 1674)
+++ code/branches/gui/src/orxonox/objects/Backlight.cc	(revision 1686)
@@ -32,4 +32,5 @@
 #include <OgreBillboard.h>
 #include <OgreRibbonTrail.h>
+#include <OgreSceneManager.h>
 
 #include "core/CoreIncludes.h"
Index: code/branches/gui/src/orxonox/objects/ParticleSpawner.cc
===================================================================
--- code/branches/gui/src/orxonox/objects/ParticleSpawner.cc	(revision 1674)
+++ code/branches/gui/src/orxonox/objects/ParticleSpawner.cc	(revision 1686)
@@ -30,4 +30,5 @@
 #include "ParticleSpawner.h"
 
+#include <OgreSceneManager.h>
 #include "core/CoreIncludes.h"
 #include "core/Executor.h"
Index: code/branches/gui/src/orxonox/objects/WorldEntity.cc
===================================================================
--- code/branches/gui/src/orxonox/objects/WorldEntity.cc	(revision 1674)
+++ code/branches/gui/src/orxonox/objects/WorldEntity.cc	(revision 1686)
@@ -32,4 +32,5 @@
 #include <string>
 #include <sstream>
+#include <OgreSceneManager.h>
 
 #include "tinyxml/tinyxml.h"
Index: code/branches/gui/src/orxonox/objects/WorldEntity.h
===================================================================
--- code/branches/gui/src/orxonox/objects/WorldEntity.h	(revision 1674)
+++ code/branches/gui/src/orxonox/objects/WorldEntity.h	(revision 1686)
@@ -31,8 +31,7 @@
 
 #include "OrxonoxPrereqs.h"
-
-#include <OgreSceneManager.h>
+#include <OgrePrerequisites.h>
+
 #include <OgreSceneNode.h>
-
 #include "util/Math.h"
 #include "util/XMLIncludes.h"
