tgTimer.cpp
Go to the documentation of this file.
00001 
00002 #include <blort/TomGine/tgTimer.h>
00003 
00004 using namespace TomGine;
00005 
00006 // ***********************************************************************************
00007 
00008 tgTimer::tgTimer(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 tgTimer::~tgTimer(void) {
00021 }
00022 
00023 void tgTimer::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 tgTimer::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): Michael Zillich, Thomas Mörwald, Johann Prankl, Andreas Richtsfeld, Bence Magyar (ROS version)
autogenerated on Thu Jan 2 2014 11:38:26