00001 /* 00002 * $Id: framerate.h 409 2008-10-20 19:01:03Z kybav1 $ 00003 * 00004 * Description : One line description of file. 00005 * Author : Vaclav Kyba <mail/Jabber: vaseo1@gmail.com> <ICQ: 98576293> 00006 * 00007 * Purpose : 00008 * Long description of what the file is for. 00009 */ 00010 00011 00012 #ifndef __FRAMERATE__H__ 00013 #define __FRAMERATE__H__ 00014 00015 #include <wx/stopwatch.h> 00016 00017 00018 namespace VRUT 00019 { 00021 class FrameRate 00022 { 00023 protected: 00025 unsigned long totalFrames; 00027 unsigned long lastFrames; 00029 float fps; 00031 wxStopWatch stopWatch; 00032 00033 public: 00035 FrameRate() 00036 { 00037 totalFrames = lastFrames = 0; 00038 fps = 0; 00039 } 00040 00042 float GetFPS() const 00043 { 00044 return fps; 00045 } 00046 00048 void IncFrame() 00049 { 00050 totalFrames++; 00051 long currTime = stopWatch.Time(); 00052 if (currTime > 500) 00053 { 00054 fps = 1000.0f * double(totalFrames - lastFrames) / double(currTime); 00055 if (totalFrames > 0x0fffffff) 00056 totalFrames = 0; 00057 lastFrames = totalFrames; 00058 stopWatch.Start(); 00059 } 00060 } 00061 }; 00062 }; 00063 00064 00065 #endif
1.5.5