raSystem  1.0 bata
raTimer.cpp
Go to the documentation of this file.
1 #include "..\include\raMain.h"
2 
3 namespace System
4 {
6 {
7  QueryPerformanceFrequency( (LARGE_INTEGER *)&m_ticksPerSecond );
8 
9  m_currentTime = m_lastTime = 0;
10  m_runningTime = 0.0f;
11  m_timerStopped = true;
12  m_timeElapsed = 0.0f;
13 }
14 raTimer::raTimer(const GUID& raguid)
15 {
16  QueryPerformanceFrequency( (LARGE_INTEGER *)&m_ticksPerSecond );
17 
18  m_currentTime = m_lastTime = 0;
19  m_runningTime = 0.0f;
20  m_timerStopped = true;
21  m_timeElapsed = 0.0f;
22 }
24 {
25  Stop();
26 }
27 void raTimer::Start(void)
28 {
29  if (!m_timerStopped)
30  return;
31  QueryPerformanceCounter( (LARGE_INTEGER *)&m_lastTime );
32  m_timerStopped = false;
33 }
34 void raTimer::Stop(void)
35 {
36  if(m_timerStopped)
37  return;
38  INT64 stopTime = 0;
39  QueryPerformanceCounter( (LARGE_INTEGER *)&stopTime );
40  m_runningTime += (float)(stopTime - m_lastTime) / (float)m_ticksPerSecond;
41  m_timerStopped = true;
42 }
43 void raTimer::UpDate(void)
44 {
45  if (m_timerStopped)
46  return;
47  QueryPerformanceCounter( (LARGE_INTEGER *)&m_currentTime );
48 
49  m_timeElapsed = (float)(m_currentTime - m_lastTime) / (float)m_ticksPerSecond;
50  m_runningTime += m_timeElapsed;
51 
52  m_lastTime = m_currentTime;
53 }
54 void raTimer::Reset(void)
55 {
56  m_runningTime = 0.0f;
57  m_lastTime = 0;
58 }
59 };
~raTimer(void)
Definition: raTimer.cpp:23
void Reset(void)
Definition: raTimer.cpp:54
void UpDate(void)
Definition: raTimer.cpp:43
void Stop(void)
Definition: raTimer.cpp:34
raTimer(void)
Definition: raTimer.cpp:5
void Start(void)
Definition: raTimer.cpp:27