Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 25, 2009, 2:14:05 PM (15 years ago)
Author:
rgrieder
Message:

Moved InputManager, GUIManager and GraphicsManager handling from GSGraphics to Core.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource/src/core/Core.cc

    r3348 r3349  
    4141#include <cstdio>
    4242#include <boost/filesystem.hpp>
     43#include <OgreRenderWindow.h>
    4344
    4445#ifdef ORXONOX_PLATFORM_WINDOWS
     
    6970#include "Factory.h"
    7071#include "GameMode.h"
     72#include "GraphicsManager.h"
     73#include "GUIManager.h"
    7174#include "Identifier.h"
    7275#include "Language.h"
     
    7578#include "TclBind.h"
    7679#include "TclThreadManager.h"
     80#include "input/InputManager.h"
    7781
    7882namespace orxonox
     
    346350            return;
    347351
     352        // Load OGRE including the render window
     353        this->graphicsManager_ = new GraphicsManager();
     354
     355        // The render window width and height are used to set up the mouse movement.
     356        size_t windowHnd = 0;
     357        Ogre::RenderWindow* renderWindow = GraphicsManager::getInstance().getRenderWindow();
     358        renderWindow->getCustomAttribute("WINDOW", &windowHnd);
     359
     360        // Calls the InputManager which sets up the input devices.
     361        inputManager_ = new InputManager(windowHnd);
     362
     363        // load the CEGUI interface
     364        guiManager_ = new GUIManager(renderWindow);
     365
    348366        GameMode::setShowsGraphics(true);
    349367        bGraphicsLoaded_ = true;
     
    354372        if (!bGraphicsLoaded_)
    355373            return;
     374
     375        delete this->guiManager_;
     376        delete this->inputManager_;
     377        delete graphicsManager_;
    356378
    357379        bGraphicsLoaded_ = false;
     
    646668    }
    647669
    648     void Core::update(const Clock& time)
    649     {
    650         this->tclThreadManager_->update(time);
     670    bool Core::preUpdate(const Clock& time) throw()
     671    {
     672        std::string exceptionMessage;
     673        try
     674        {
     675            // process input events
     676            this->inputManager_->update(time);
     677            // process gui events
     678            this->guiManager_->update(time);
     679            // process thread commands
     680            this->tclThreadManager_->update(time);
     681        }
     682        catch (const std::exception& ex)
     683        { exceptionMessage = ex.what(); }
     684        catch (...)
     685        { exceptionMessage = "Unknown exception"; }
     686        if (!exceptionMessage.empty())
     687        {
     688            COUT(0) << "An exception occurred in the Core preUpdate: " << exceptionMessage << std::endl;
     689            COUT(0) << "This should really never happen! Closing the program." << std::endl;
     690            return false;
     691        }
     692        return true;
     693    }
     694
     695    bool Core::postUpdate(const Clock& time) throw()
     696    {
     697        std::string exceptionMessage;
     698        try
     699        {
     700            // Render (doesn't throw)
     701            this->graphicsManager_->update(time);
     702        }
     703        catch (const std::exception& ex)
     704        { exceptionMessage = ex.what(); }
     705        catch (...)
     706        { exceptionMessage = "Unknown exception"; }
     707        if (!exceptionMessage.empty())
     708        {
     709            COUT(0) << "An exception occurred in the Core postUpdate: " << exceptionMessage << std::endl;
     710            COUT(0) << "This should really never happen! Closing the program." << std::endl;
     711            return false;
     712        }
     713        return true;
    651714    }
    652715}
Note: See TracChangeset for help on using the changeset viewer.