Changeset 4245 in orxonox.OLD for orxonox/trunk/src/lib/graphics
- Timestamp:
- May 20, 2005, 11:28:43 AM (20 years ago)
- 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 20 20 21 21 #include "debug.h" 22 #include "text_engine.h" 22 23 23 24 using namespace std; … … 30 31 GraphicsEngine::GraphicsEngine () 31 32 { 33 this->bDisplayFPS = false; 34 this->minFPS = 9999; 35 this->maxFPS = 0; 32 36 this->setClassName ("GraphicsEngine"); 33 37 … … 278 282 PRINT(4)(" | %d x %d\n", this->videoModes[i]->w, this->videoModes[i]->h); 279 283 } 280 281 } 284 } 285 286 287 void 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 307 void 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 11 11 12 12 #include "glincl.h" 13 14 13 #include "base_object.h" 15 14 16 // FORWARD DEFINITION \\ 15 16 class Text; 17 17 18 18 … … 45 45 static GLdouble projMat[16]; 46 46 static GLint viewPort[4]; 47 47 48 void tick(float dt); 49 void displayFPS(bool display); 48 50 49 51 … … 59 61 bool fullscreen; 60 62 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; 61 72 62 73 SDL_Rect **videoModes;
Note: See TracChangeset
for help on using the changeset viewer.