# Khaotic Engine Reborn: timer_class Class Reference

Loading...
Searching...
No Matches
timer_class Class Reference

## Public Member Functions

| timer_class (const timer_class &)
bool | Initialize ()
void | Frame ()
float | GetTime ()

## Detailed Description

Definition at line 15 of file timer_class.h.

## Constructor & Destructor Documentation

## timer_class() [1/2]

timer_class::timer_class | ( |  | ) |

Definition at line 4 of file timer_class.cpp.

{
}

## timer_class() [2/2]

timer_class::timer_class | ( | const timer_class & | other | ) |

Definition at line 9 of file timer_class.cpp.

{
}

## ~timer_class()

timer_class::~timer_class | ( |  | ) |

Definition at line 14 of file timer_class.cpp.

{
}

## Member Function Documentation

## Frame()

void timer_class::Frame | ( |  | ) |

Definition at line 44 of file timer_class.cpp.

{
INT64 currentTime;
INT64 elapsedTicks;
// Query the current time.
QueryPerformanceCounter((LARGE_INTEGER*)&currentTime);
// Calculate the difference in time since the last time we queried for the current time.
elapsedTicks = currentTime - m_startTime;
// Calculate the frame time.
m_frameTime = (float)elapsedTicks / m_frequency;
// Restart the timer.
m_startTime = currentTime;
return;
}

## GetTime()

float timer_class::GetTime | ( |  | ) |

Definition at line 65 of file timer_class.cpp.

{
return m_frameTime;
}

## Initialize()

bool timer_class::Initialize | ( |  | ) |

Definition at line 18 of file timer_class.cpp.

{
Logger::Get().Log("Initilazing timer class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
INT64 frequency;
// Get the cycles per second speed for this system.
QueryPerformanceFrequency((LARGE_INTEGER*)&frequency);
if (frequency == 0)
{
Logger::Get().Log("QueryPerformanceFrequency failed", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Store it in floating point.
m_frequency = (float)frequency;
// Get the initial start time.
QueryPerformanceCounter((LARGE_INTEGER*)&m_startTime);
Logger::Get().Log("Timer class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}

The documentation for this class was generated from the following files:

- enginecustom/src/inc/system/timer_class.h
- enginecustom/src/src/system/timer_class.cpp