Changeset 4245 in orxonox.OLD for orxonox/trunk/src/lib/graphics/graphics_engine.cc
- Timestamp:
- May 20, 2005, 11:28:43 AM (19 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.