Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 1, 2008, 7:04:09 PM (16 years ago)
Author:
landauf
Message:

merged objecthierarchy branch back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r1891 r2087  
    4747#include "core/ConfigValueIncludes.h"
    4848#include "core/CoreIncludes.h"
     49#include "core/Core.h"
    4950#include "core/input/InputManager.h"
    5051#include "core/input/KeyBinder.h"
    5152#include "core/input/ExtendedInputState.h"
     53#include "core/Loader.h"
     54#include "core/XMLFile.h"
    5255#include "overlays/console/InGameConsole.h"
    5356#include "gui/GUIManager.h"
    5457#include "tools/WindowEventListener.h"
     58#include "objects/Tickable.h"
    5559#include "Settings.h"
    5660
     
    6468        , renderWindow_(0)
    6569        , viewport_(0)
     70        , bWindowEventListenerUpdateRequired_(false)
    6671        , inputManager_(0)
    6772        , console_(0)
     
    7681        , statisticsStartCount_(0)
    7782        , tickTime_(0)
     83        , debugOverlay_(0)
    7884    {
    7985        RegisterRootObject(GSGraphics);
     
    101107    void GSGraphics::enter()
    102108    {
    103         Settings::_getInstance().bShowsGraphics_ = true;
     109        Core::setShowsGraphics(true);
    104110
    105111        // initialise graphics engine. Doesn't load the render window yet!
     
    113119        this->initialiseResources();
    114120
    115 
    116         // HACK: temporary:
    117         graphicsEngine_->renderWindow_  = this->renderWindow_;
    118         graphicsEngine_->root_          = this->ogreRoot_;
    119         graphicsEngine_->viewport_      = this->viewport_;
    120 
     121        // We want to get informed whenever an object of type WindowEventListener is created
     122        // in order to later update the window size.
     123        bWindowEventListenerUpdateRequired_ = false;
     124        RegisterConstructionCallback(GSGraphics, orxonox::WindowEventListener, requestWindowEventListenerUpdate);
     125
     126        // load debug overlay
     127        COUT(3) << "Loading Debug Overlay..." << std::endl;
     128        this->debugOverlay_ = new XMLFile(Settings::getDataPath() + "overlay/debug.oxo");
     129        Loader::open(debugOverlay_);
    121130
    122131        // Calls the InputManager which sets up the input devices.
     
    133142        // Load the InGameConsole
    134143        console_ = new InGameConsole();
    135         console_->initialise();
     144        console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
    136145
    137146        // load the CEGUI interface
     
    165174        //delete this->masterKeyBinder_;
    166175        delete this->inputManager_;
     176
     177        Loader::unload(this->debugOverlay_);
     178        delete this->debugOverlay_;
    167179
    168180        // destroy render window
     
    196208        delete graphicsEngine_;
    197209
    198         Settings::_getInstance().bShowsGraphics_ = false;
     210        Core::setShowsGraphics(false);
    199211    }
    200212
     
    221233        this->console_->tick(dt);
    222234        this->tickChild(time);
    223        
     235
     236        /*** HACK *** HACK ***/
     237        // Call the Tickable objects
     238        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
     239            it->tick(time.getDeltaTime());
     240        /*** HACK *** HACK ***/
     241
     242        if (this->bWindowEventListenerUpdateRequired_)
     243        {
     244            // Update all WindowEventListeners for the case a new one was created.
     245            this->windowResized(this->renderWindow_);
     246            this->bWindowEventListenerUpdateRequired_ = false;
     247        }
     248
    224249        unsigned long long timeAfterTick = time.getRealMicroseconds();
    225250
     
    487512        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    488513            it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
     514
     515        // OIS needs this under linux even if we only use relative input measurement.
     516        if (this->inputManager_)
     517            this->inputManager_->setWindowExtents(renderWindow_->getWidth(), renderWindow_->getHeight());
    489518    }
    490519
     
    501530
    502531        // instruct InputManager to clear the buffers (core library so we cannot use the interface)
    503         InputManager::getInstance().clearBuffers();
     532        if (this->inputManager_)
     533            this->inputManager_->clearBuffers();
    504534    }
    505535
     
    512542    void GSGraphics::windowClosed(Ogre::RenderWindow *rw)
    513543    {
    514         // using CommandExecutor in order to avoid depending on Orxonox.h.
    515         //CommandExecutor::execute("exit", false);
    516544        this->requestState("root");
    517545    }
Note: See TracChangeset for help on using the changeset viewer.