#include <timer.h>
Public Member Functions | |
Timer () | |
Timer constructor. | |
void | ResetTime () |
Reset time zero position. | |
double | GetDeltaTime () |
Get time difference. | |
double | GetDeltaTime (double max_fps) |
Get time difference with a lower limit by max fps. | |
double | GetTime () |
Get current time. | |
Private Attributes | |
double | m_zero |
double | m_time |
A high performance timer for Windows and Linux.
Timer::Timer | ( | ) |
Timer constructor.
Reads the counter frequency if in Windows and resets time.
void Timer::ResetTime | ( | ) |
Reset time zero position.
Set reference time to current time or counter value to be used when calculating time differences. This method is called from the constructor.
double Timer::GetDeltaTime | ( | ) |
Get time difference.
Reads the current time and return the difference since the last time this method was invoked. The first time it returns the time since the class was initilized or the last time ResetTime was invoked.
double Timer::GetDeltaTime | ( | double | max_fps | ) |
Get time difference with a lower limit by max fps.
Reads the current time and return the difference since the last time this method was invoked, but if the deltatime is lower than 1/max_fps it will wait until that time is reached. The first time it uses the time since the class was initilized or the last time ResetTime was invoked as reference.
max_fps | Maximal number of frames per second. |
double Timer::GetTime | ( | ) |
Get current time.
Reads the QueryPerformanceCounter if in Windows or uses gettimeofday to read current time. Then converts it to seconds.
double Timer::m_zero [private] |
Time defined as zero
double Timer::m_time [private] |
Current time