Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4849 in orxonox.OLD


Ignore:
Timestamp:
Jul 13, 2005, 7:03:05 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: the crosshair now renders as element2d

Location:
orxonox/trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/defs/include_paths.am

    r4842 r4849  
    1010AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics/importer
    1111AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics/spatial_separation
     12AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics/render2D
    1213AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/particles
    1314AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/gui
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r4838 r4849  
    2020#include "event_handler.h"
    2121
     22#include "render_2d.h"
    2223#include "debug.h"
    2324#include "text_engine.h"
     
    5859{
    5960  // delete what has to be deleted here
     61
     62  delete Render2D::getInstance();
     63  GraphicsEngine::singletonRef = NULL;
    6064}
    6165
     
    148152  glEnable(GL_DEPTH_TEST);
    149153
    150 
    151   // subscribe the resolutionChanged-event
    152   //EventHandler::getInstance()->subscribe(this, ES_GAME, EV_VIDEO_RESIZE);
    153   //! @todo eventSystem craps up the Starting of orxonox -> see why.
     154  Render2D::getInstance();
    154155
    155156  this->isInit = true;
     
    402403 * @param dt the time passed
    403404*/
    404 void GraphicsEngine::tick(float dt)
     405  void GraphicsEngine::tick(float dt)
    405406{
    406407  if( unlikely(this->bDisplayFPS))
    407     {
    408       this->currentFPS = 1.0/dt;
    409       if( unlikely(this->currentFPS > this->maxFPS)) this->maxFPS = this->currentFPS;
    410       if( unlikely(this->currentFPS < this->minFPS)) this->minFPS = this->currentFPS;
     408  {
     409    this->currentFPS = 1.0/dt;
     410    if( unlikely(this->currentFPS > this->maxFPS)) this->maxFPS = this->currentFPS;
     411    if( unlikely(this->currentFPS < this->minFPS)) this->minFPS = this->currentFPS;
    411412
    412413#ifndef NO_TEXT
     
    421422      this->geTextMinFPS->setText(tmpChar3);
    422423#endif /* NO_TEXT */
    423     }
     424
     425
     426  }
     427  Render2D::getInstance()->tick(dt);
     428
     429}
     430
     431
     432void GraphicsEngine::draw() const
     433{
     434  Render2D::getInstance()->draw();
     435
    424436}
    425437
  • orxonox/trunk/src/lib/graphics/graphics_engine.h

    r4836 r4849  
    6363
    6464    void tick(float dt);
     65    void draw() const;
    6566    void displayFPS(bool display);
    6667
  • orxonox/trunk/src/lib/graphics/render2D/element_2d.h

    r4848 r4849  
    4343
    4444//! A class for ...
    45 class Element2D : public BaseObject {
     45class Element2D : virtual public BaseObject {
    4646
    4747 public:
  • orxonox/trunk/src/lib/graphics/render2D/render_2d.cc

    r4848 r4849  
    7777
    7878
     79void Render2D::tick(float dt)
     80{
     81  tIterator<Element2D>* iterator = this->element2DList->getIterator();
     82  Element2D* elem = iterator->nextElement();
     83  while (elem != NULL)
     84  {
     85    elem->tick(dt);
     86    elem = iterator->nextElement();
     87  }
     88  delete iterator;
     89
     90}
     91
     92/**
     93 * renders all the Elements of the Render2D-engine
     94 */
    7995void Render2D::draw() const
    8096{
  • orxonox/trunk/src/lib/graphics/render2D/render_2d.h

    r4848 r4849  
    2121  inline static Render2D* getInstance() { if (!singletonRef) singletonRef = new Render2D();  return singletonRef; };
    2222
    23 
     23  void tick(float dt);
    2424  void draw() const;
    2525
  • orxonox/trunk/src/story_entities/world.cc

    r4838 r4849  
    849849  ParticleEngine::getInstance()->draw();
    850850
    851 
     851  GraphicsEngine::getInstance()->draw();
    852852  TextEngine::getInstance()->draw();
    853853  LightManager::getInstance()->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
  • orxonox/trunk/src/world_entities/weapons/crosshair.cc

    r4838 r4849  
    180180 * draws the crosshair
    181181 */
    182 void Crosshair::draw()
     182void Crosshair::draw() const
    183183{
    184184  GraphicsEngine::storeMatrices();
  • orxonox/trunk/src/world_entities/weapons/crosshair.h

    r4836 r4849  
    88#define _CROSSHAIR_H
    99
     10#include "p_node.h"
     11#include "element_2d.h"
    1012#include "event_listener.h"
    11 #include "p_node.h"
     13
    1214#include "vector.h"
     15
    1316
    1417// FORWARD DEFINITION
     
    1821
    1922//! A class that enables the
    20 class Crosshair : public PNode, public EventListener {
     23class Crosshair : public PNode, public Element2D, public EventListener {
    2124
    2225 public:
     
    3336
    3437  virtual void process(const Event &event);
    35   void tick(float dt);
    36   void draw();
     38  virtual void tick(float dt);
     39  virtual void draw() const;
    3740
    3841 private:
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.cc

    r4837 r4849  
    243243  }
    244244
    245   crosshair->tick(dt);
    246245  crosshair->setRotationSpeed(5);
    247246}
     
    260259      w->draw();
    261260  }
    262   crosshair->draw();
    263261}
    264262
Note: See TracChangeset for help on using the changeset viewer.