Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4066 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 5, 2005, 8:59:01 PM (20 years ago)
Author:
patrick
Message:

orxonox/branches/md2_loader: now it displays the fps, will do this better an look for a good font.

Location:
orxonox/branches/md2_loader/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/md2_loader/src/lib/graphics/graphics_engine.cc

    r4065 r4066  
    1919
    2020#include "debug.h"
     21#include "text_engine.h"
    2122
    2223using namespace std;
     
    2930GraphicsEngine::GraphicsEngine ()
    3031{
     32  this->bDisplayFPS = false;
    3133  this->setClassName ("GraphicsEngine");
    3234  this->initVideo();
     
    263265  }
    264266}
    265  
    266 void GraphicsEngine::displayFPS(bool dislay)
    267 {
    268         PRINTF(4)("");
    269        
    270        
    271 }
    272 
    273  
     267
     268
     269void GraphicsEngine::tick(float dt)
     270{
     271        if( unlikely(this->bDisplayFPS))
     272        {
     273          this->currentFPS = 1.0/dt;
     274      if( unlikely(this->currentFPS > this->maxFPS)) this->maxFPS = this->currentFPS;
     275          if( unlikely(this->currentFPS < this->minFPS)) this->minFPS = this->currentFPS;
     276         
     277          // temporary, only for showing how fast the text-engine is
     278          char tmpChar[20];
     279          sprintf(tmpChar, "fps: %4.0f", this->currentFPS);
     280          this->geText->setPosition(0, 500);
     281          this->geText->setText(tmpChar);
     282          //this->geText->setPosition(0, 420);
     283          //this->geText->setText("TEST");
     284        }
     285}
     286 
     287void GraphicsEngine::displayFPS(bool display)
     288{
     289  this->geText = TextEngine::getInstance()->createText("fonts/earth.ttf", 30, TEXT_DYNAMIC, 0, 255, 0);
     290  this->geText->setAlignment(TEXT_ALIGN_LEFT);
     291  this->bDisplayFPS = display;
     292}
     293
     294 
  • orxonox/branches/md2_loader/src/lib/graphics/graphics_engine.h

    r4065 r4066  
    1111
    1212#include "glincl.h"
    13 
    1413#include "base_object.h"
    1514
    16 // FORWARD DEFINITION \\
     15
     16class Text;
    1717
    1818
     
    4545  static GLint viewPort[4];
    4646 
    47   void displayFPS(bool dislay);
     47  void tick(float dt);
     48  void displayFPS(bool display);
    4849
    4950
     
    5960  bool fullscreen;
    6061  Uint32 videoFlags;
     62 
     63  bool bDisplayFPS;  //!< is true if the fps should be displayed
     64  float currentFPS;  //!< the current frame rate: frames per seconds
     65  float maxFPS;      //!< maximal frame rate we ever got since start of the game
     66  float minFPS;      //!< minimal frame rate we ever got since start
     67
     68  Text* geText;
    6169
    6270  SDL_Rect **videoModes;
  • orxonox/branches/md2_loader/src/story_entities/world.cc

    r4015 r4066  
    4040#include "garbage_collector.h"
    4141#include "animation_player.h"
     42#include "graphics_engine.h"
    4243
    4344#include "command_node.h"
     
    258259  this->localCamera = new Camera();
    259260  this->localCamera->setName ("camera");
     261 
     262  GraphicsEngine::getInstance()->displayFPS(true);
    260263}
    261264
     
    11151118      this->localCamera->tick(this->dt);
    11161119      this->garbageCollector->tick(seconds);
    1117 
    1118       AnimationPlayer::getInstance()->tick(seconds);
     1120         
     1121          /* actualy the Graphics Engine should tick the world not the other way around...
     1122                 but since we like the things not too complicated we got it this way around
     1123                 until there is need or time to do it the other way around.
     1124                 \todo: GraphicsEngine ticks world: separation of processes and data...
     1125          */
     1126      GraphicsEngine::getInstance()->tick(seconds);
     1127          AnimationPlayer::getInstance()->tick(seconds);
    11191128    }
    11201129  this->lastFrame = currentFrame;
Note: See TracChangeset for help on using the changeset viewer.