$search
00001 00002 #ifndef TIMER_H 00003 #define TIMER_H 00004 #pragma once 00005 00006 #ifdef _WIN32 00007 #include <windows.h> 00008 #else 00009 #include <time.h> 00010 #include <sys/time.h> 00011 #endif 00012 00013 // *********************************************************************************** 00014 00015 namespace Tracking{ 00016 00017 class Timer 00018 { 00019 private: 00020 #ifdef WIN32 00021 LONGLONG m_StartTicks; // QueryPerformance - Ticks at application start 00022 LONGLONG m_EndTicks; // QueryPerformance - Ticks when calling Now() 00023 LONGLONG m_Frequency; // QueryPerformance - Fequency 00024 double fNow; 00025 #else 00026 struct timespec AppStart, act, old; 00027 #endif 00028 double m_fAppTime; // Time since application started 00029 double m_fTime; // Time between two Update calls 00030 00031 00032 public: 00033 Timer(void); 00034 ~Timer(void); 00035 00036 void Reset(); 00037 double Update(); 00038 00039 double GetFrameTime(){ return m_fTime;} 00040 double GetApplicationTime(){ return m_fAppTime;} 00041 00042 }; 00043 00044 } 00045 00046 #endif 00047