Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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).

File:
1 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 
Note: See TracChangeset for help on using the changeset viewer.