Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 8, 2008, 5:55:05 PM (17 years ago)
Author:
rgrieder
Message:
  • changed a default value concerning the derived mouse input (maybe change that in orxonox.ini too
  • added initialise()/destroy() to HUD in order to avoid a segfault
Location:
code/trunk/src/orxonox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/Orxonox.cc

    r1563 r1567  
    116116  {
    117117    // keep in mind: the order of deletion is very important!
    118 //    if (this->orxonoxHUD_)
    119 //      delete this->orxonoxHUD_;
     118    this->orxonoxHUD_->destroy();
    120119    Loader::close();
    121120    InputManager::destroy();
     
    331330    COUT(3) << "Orxonox: Loading HUD..." << std::endl;
    332331    orxonoxHUD_ = &HUD::getSingleton();
     332    orxonoxHUD_->initialise();
    333333    return true;
    334334  }
  • code/trunk/src/orxonox/hud/HUD.cc

    r1564 r1567  
    4646#include "RadarOverlayElement.h"
    4747#include "Navigation.h"
    48 #include "OverlayElementFactories.h"
    4948
    5049namespace orxonox
     
    5958    HUD::HUD()
    6059    {
     60        orxonoxHUD_ = 0;
     61        container_ = 0;
     62        fpsText_ = 0;
     63        rTRText_ = 0;
     64        energyBar_ = 0;
     65        speedoBar_ = 0;
     66        radar_ = 0;
     67        nav_ = 0;
     68        bool showFPS_ = true;
     69        bool showRenderTime_ = true;
     70    }
     71
     72    HUD::~HUD()
     73    {
     74        this->destroy();
     75    }
     76
     77    void HUD::initialise()
     78    {
    6179        showFPS_ = true;
    6280        showRenderTime_ = true;
    6381
    6482        // create Factories
    65         barOverlayElementFactory_ = new BarOverlayElementFactory();
    66         Ogre::OverlayManager::getSingleton().addOverlayElementFactory(barOverlayElementFactory_);
    67         radarOverlayElementFactory_ = new RadarOverlayElementFactory();
    68         Ogre::OverlayManager::getSingleton().addOverlayElementFactory(radarOverlayElementFactory_);
     83        Ogre::OverlayManager::getSingleton().addOverlayElementFactory(&barOverlayElementFactory_);
     84        Ogre::OverlayManager::getSingleton().addOverlayElementFactory(&radarOverlayElementFactory_);
    6985
    7086        orxonoxHUD_ = Ogre::OverlayManager::getSingleton().create("Orxonox/HUD");
     
    139155    }
    140156
    141     HUD::~HUD()
    142     {
    143         Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->container_);
    144         Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->fpsText_);
    145         Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->rTRText_);
    146         Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->energyBar_);
    147         Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->speedoBar_);
    148         Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->radar_);
    149 
    150         delete this->nav_;
    151         delete this->barOverlayElementFactory_;
    152         delete this->radarOverlayElementFactory_;
     157    void HUD::destroy()
     158    {
     159        if (this->container_)
     160          Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->container_);
     161        this->container_ = 0;
     162        if (this->fpsText_)
     163            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->fpsText_);
     164        this->fpsText_ = 0;
     165        if (this->rTRText_)
     166            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->rTRText_);
     167        this->rTRText_ = 0;
     168        if (this->energyBar_)
     169            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->energyBar_);
     170        this->energyBar_ = 0;
     171        if (this->speedoBar_)
     172            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->speedoBar_);
     173        this->speedoBar_ = 0;
     174        if (this->radar_)
     175            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->radar_);
     176        this->radar_ = 0;
     177        if (this->orxonoxHUD_)
     178            Ogre::OverlayManager::getSingleton().destroy(this->orxonoxHUD_);
     179        this->orxonoxHUD_ = 0;
     180
     181        if (this->nav_)
     182            delete this->nav_;
     183        this->nav_ = 0;
    153184    }
    154185
  • code/trunk/src/orxonox/hud/HUD.h

    r1564 r1567  
    3737#include "objects/Tickable.h"
    3838#include "util/Math.h"
     39#include "OverlayElementFactories.h"
    3940
    4041namespace orxonox
     
    4344    {
    4445      public:
    45         static HUD& getSingleton();
     46        void initialise();
     47        void destroy();
     48
    4649        virtual void tick(float);
    4750
     
    5457        inline std::list<RadarObject*>& getRadarObjects()
    5558            { return this->roSet_; }
     59
     60        static HUD& getSingleton();
    5661
    5762        static void setEnergy(float value);
     
    6671        ~HUD();
    6772
    68         static HUD* instance_s;
     73        std::list<RadarObject*> roSet_;
     74        BarOverlayElementFactory barOverlayElementFactory_;
     75        RadarOverlayElementFactory radarOverlayElementFactory_;
    6976
    70         std::list<RadarObject*> roSet_;
    7177        Ogre::Overlay* orxonoxHUD_;
    7278        Ogre::OverlayContainer* container_;
    73         BarOverlayElementFactory* barOverlayElementFactory_;
    74         RadarOverlayElementFactory* radarOverlayElementFactory_;
    7579        Ogre::TextAreaOverlayElement* fpsText_;
    7680        Ogre::TextAreaOverlayElement* rTRText_;
Note: See TracChangeset for help on using the changeset viewer.