Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4245 in orxonox.OLD for orxonox/trunk/src/lib/graphics


Ignore:
Timestamp:
May 20, 2005, 11:28:43 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: merged back the md2_loader branche manualy (a full merge was impossible).

Location:
orxonox/trunk/src/lib/graphics
Files:
5 added
2 edited

Legend:

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

    r4135 r4245  
    2020
    2121#include "debug.h"
     22#include "text_engine.h"
    2223
    2324using namespace std;
     
    3031GraphicsEngine::GraphicsEngine ()
    3132{
     33  this->bDisplayFPS = false;
     34  this->minFPS = 9999;
     35  this->maxFPS = 0;
    3236  this->setClassName ("GraphicsEngine");
    3337
     
    278282      PRINT(4)(" |  %d x %d\n", this->videoModes[i]->w, this->videoModes[i]->h);
    279283  }
    280  
    281 }
     284}
     285
     286
     287void GraphicsEngine::tick(float dt)
     288{
     289        if( unlikely(this->bDisplayFPS))
     290        {
     291          this->currentFPS = 1.0/dt;
     292      if( unlikely(this->currentFPS > this->maxFPS)) this->maxFPS = this->currentFPS;
     293          if( unlikely(this->currentFPS < this->minFPS)) this->minFPS = this->currentFPS;
     294         
     295          char tmpChar1[20];
     296          sprintf(tmpChar1, "Current:  %4.0f", this->currentFPS);
     297          this->geTextCFPS->setText(tmpChar1);
     298          char tmpChar2[20];
     299          sprintf(tmpChar2, "Max:    %4.0f", this->maxFPS);
     300          this->geTextMaxFPS->setText(tmpChar2);
     301          char tmpChar3[20];
     302          sprintf(tmpChar3, "Min:    %4.0f", this->minFPS);
     303          this->geTextMinFPS->setText(tmpChar3);
     304        }
     305}
     306 
     307void GraphicsEngine::displayFPS(bool display)
     308{
     309        if( display)
     310        {
     311                this->geTextCFPS = TextEngine::getInstance()->createText("fonts/druid.ttf", 35, TEXT_DYNAMIC, 0, 255, 0);
     312                this->geTextCFPS->setAlignment(TEXT_ALIGN_LEFT);
     313                this->geTextCFPS->setPosition(5, 500);
     314                this->geTextMaxFPS = TextEngine::getInstance()->createText("fonts/druid.ttf", 35, TEXT_DYNAMIC, 0, 255, 0);
     315                this->geTextMaxFPS->setAlignment(TEXT_ALIGN_LEFT);
     316                this->geTextMaxFPS->setPosition(5, 530);
     317                this->geTextMinFPS = TextEngine::getInstance()->createText("fonts/druid.ttf", 35, TEXT_DYNAMIC, 0, 255, 0);
     318                this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT);
     319                this->geTextMinFPS->setPosition(5, 560);       
     320        }
     321        this->bDisplayFPS = display;
     322}
     323
     324 
  • orxonox/trunk/src/lib/graphics/graphics_engine.h

    r4135 r4245  
    1111
    1212#include "glincl.h"
    13 
    1413#include "base_object.h"
    1514
    16 // FORWARD DEFINITION \\
     15
     16class Text;
    1717
    1818
     
    4545  static GLdouble projMat[16];
    4646  static GLint viewPort[4];
    47 
     47 
     48  void tick(float dt);
     49  void displayFPS(bool display);
    4850
    4951
     
    5961  bool fullscreen;
    6062  Uint32 videoFlags;
     63 
     64  bool bDisplayFPS;  //!< is true if the fps should be displayed
     65  float currentFPS;  //!< the current frame rate: frames per seconds
     66  float maxFPS;      //!< maximal frame rate we ever got since start of the game
     67  float minFPS;      //!< minimal frame rate we ever got since start
     68
     69  Text* geTextCFPS;
     70  Text* geTextMaxFPS;
     71  Text* geTextMinFPS;
    6172
    6273  SDL_Rect **videoModes;
Note: See TracChangeset for help on using the changeset viewer.