Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 19, 2008, 8:12:15 PM (16 years ago)
Author:
rgrieder
Message:
  • Changed static Executor/Functor in ConsoleCommand to generic one that enables console commands for member functions. (This is more of a temporary solution, but can be made permanent with right adjustments)
  • The whole GameState thing seems to works so far. But I there's only standalone mode at the moment
  • Console now shows in GUI too. I will have to implement a master InputState in the InputManager (little bit of a break with the concept, but probably necessary)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/orxonox/gamestates/GSGraphics.cc

    r1661 r1662  
    3535#include <OgreWindowEventUtilities.h>
    3636
     37#include "core/ConsoleCommand.h"
     38#include "core/ConfigValueIncludes.h"
    3739#include "core/input/InputManager.h"
    38 #include "core/input/SimpleInputState.h"
    39 #include "core/input/KeyBinder.h"
    4040#include "core/Core.h"
    41 
    42 #include "GraphicsEngine.h"
    4341#include "overlays/console/InGameConsole.h"
    4442#include "gui/GUIManager.h"
     43#include "GraphicsEngine.h"
    4544
    4645namespace orxonox
     
    8887        guiManager_ = new GUIManager();
    8988        guiManager_->initialise();
     89
     90        // use the ogre timer class to measure time.
     91        timer_ = new Ogre::Timer();
     92
     93        // add console commands
     94        FunctorMember<GSGraphics>* functor = createFunctor(&GSGraphics::exitGame);
     95        functor->setObject(this);
     96        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "exit"));
    9097    }
    9198
    9299    void GSGraphics::leave()
    93100    {
    94         if (this->guiManager_)
    95           delete guiManager_;
    96 
    97         if (this->console_)
    98           delete this->console_;
    99 
    100         if (inputManager_)
    101           delete inputManager_;
    102 
    103         // TODO: deintialise graphics
    104     }
    105 
     101        delete this->timer_;
     102
     103        delete this->guiManager_;
     104
     105        delete this->console_;
     106
     107        delete this->inputManager_;
     108
     109        // TODO: destroy render window
     110    }
     111
     112    /**
     113        Main loop of the orxonox game.
     114        We use the Ogre::Timer to measure time since it uses the most precise
     115        method an a platform (however the windows timer lacks time when under
     116        heavy kernel load!).
     117        There is a simple mechanism to measure the average time spent in our
     118        ticks as it may indicate performance issues.
     119        A note about the Ogre::FrameListener: Even though we don't use them,
     120        they still get called. However, the delta times are not correct (except
     121        for timeSinceLastFrame, which is the most important). A little research
     122        as shown that there is probably only one FrameListener that doesn't even
     123        need the time. So we shouldn't run into problems.
     124    */
    106125    bool GSGraphics::tick(float dt)
    107126    {
     127        // note: paramter 'dt' is of no meaning
     128
    108129        Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
    109 
    110         // use the ogre timer class to measure time.
    111         if (!timer_)
    112             timer_ = new Ogre::Timer();
    113130
    114131        unsigned long frameCount = 0;
     
    146163                    this->getActiveChild()->tick(dt);
    147164
     165                // tick console
     166                this->console_->tick(dt);
     167
    148168                // get current time once again
    149169                timeAfterTick = timer_->getMicroseconds();
Note: See TracChangeset for help on using the changeset viewer.