Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

FPS.H

Go to the documentation of this file.
00001 
00010 /*
00011   In a method that gets called once per frame put:
00012   double fps = FPS::update_fps();
00013 */
00014 
00015 #ifndef FPS_H
00016 #define FPS_H
00017 
00018 // Gluebase includes
00019 #define OUTSIDE_GLUE_CORE
00020 #include <std/time.H>
00021 
00022 class FPS 
00023 {
00024  public:
00025 
00026   static double fps() {
00027     return _fps;
00028   }
00029 
00030   static double update_fps() {
00031     _fcount++;
00032 
00033     if (_fcount >= _numFrames) { 
00034       double now = the_time();
00035       _fps = _numFrames / (now - _lastTick);
00036       _lastTick = the_time();
00037       _fcount = 0;
00038     }
00039     return _fps;
00040   }
00041   
00042   
00043  protected:
00044 
00045   static double _lastTick;
00046   static double _fps;
00047   static int    _fcount;
00048   static int    _numFrames;
00049 
00050 };
00051 
00052 #endif

Generated on Mon Sep 15 16:27:55 2003 for inspace by doxygen1.2.18