Timer.cpp
Go to the documentation of this file.
00001 
00002 #include <blort/Tracker/Timer.h>
00003 
00004 // ***********************************************************************************
00005 
00006 using namespace Tracking;
00007 
00008 Timer::Timer(void) {
00009 #ifdef WIN32
00010         QueryPerformanceFrequency((LARGE_INTEGER*) &m_Frequency);
00011         QueryPerformanceCounter((LARGE_INTEGER*)(&m_StartTicks));
00012         m_EndTicks = m_StartTicks;
00013 #else
00014         clock_gettime(CLOCK_REALTIME, &AppStart);
00015         clock_gettime(CLOCK_REALTIME, &old);
00016 #endif
00017         m_fAppTime = 0.0;
00018 }
00019 
00020 Timer::~Timer(void) {
00021 }
00022 
00023 void Timer::Reset() {
00024 #ifdef WIN32
00025         QueryPerformanceFrequency((LARGE_INTEGER*) &m_Frequency);
00026         QueryPerformanceCounter((LARGE_INTEGER*)(&m_StartTicks));
00027         m_EndTicks = m_StartTicks;
00028 #else
00029         clock_gettime(CLOCK_REALTIME, &AppStart);
00030         clock_gettime(CLOCK_REALTIME, &old);
00031 #endif
00032         m_fAppTime = 0.0;
00033 }
00034 
00035 double Timer::Update() {
00036 #ifdef WIN32
00037         QueryPerformanceCounter((LARGE_INTEGER*)(&m_EndTicks));
00038         fNow = (double)(m_EndTicks - m_StartTicks) / m_Frequency;
00039         m_fTime = fNow - m_fAppTime;
00040         m_fAppTime = fNow;
00041 #else
00042         clock_gettime(CLOCK_REALTIME, &act);
00043         m_fTime = (act.tv_sec - old.tv_sec) + (act.tv_nsec - old.tv_nsec) / 1e9;
00044         old = act;              
00045         m_fAppTime += m_fTime;
00046 #endif
00047         return m_fTime;
00048 }


blort
Author(s): Thomas Mörwald , Michael Zillich , Andreas Richtsfeld , Johann Prankl , Markus Vincze , Bence Magyar
autogenerated on Wed Aug 26 2015 15:24:12