![]() |
Ankush's Garage
A collection of stuff made by Ankush Roy
|
Utility class for handling delta time and FPS capping. More...
#include <Time.h>
Static Public Member Functions | |
static void | updateDeltaTime () noexcept |
Updates the delta time value. | |
static void | init () noexcept |
Initializes the time tracking system. | |
static double | deltaTime () noexcept |
Retrieves the time elapsed between the last two frames. | |
static uint32_t | getTicks () noexcept |
Gets the time in milliseconds since the start of the program. | |
static void | capFPS () |
Caps the FPS to the target frame rate. | |
Static Private Attributes | |
static double | mDeltaTime = 0.0 |
Stores the delta time value in seconds. | |
static std::chrono::time_point< std::chrono::high_resolution_clock > | mPreviousTime |
Stores the previous frame's timestamp. | |
static std::chrono::time_point< std::chrono::high_resolution_clock > | mCurrentTime |
Stores the current frame's timestamp. | |
static std::chrono::time_point< std::chrono::high_resolution_clock > | mStartTime |
Stores the program start timestamp. | |
static const int | mTargetFPS = 60 |
The target frames per second. | |
static const std::chrono::milliseconds | mFrameDuration |
The expected duration of each frame. | |
Utility class for handling delta time and FPS capping.
This class provides static methods to manage delta timing, which measures the time elapsed between frames, and functions for retrieving program ticks.
|
static |
Caps the FPS to the target frame rate.
This function ensures that the frame rate does not exceed a predefined limit.
|
staticnoexcept |
Retrieves the time elapsed between the last two frames.
|
staticnoexcept |
Gets the time in milliseconds since the start of the program.
|
staticnoexcept |
Initializes the time tracking system.
This method sets the start time and initializes the timing variables. This function should be called only once during initialisation.
|
staticnoexcept |
Updates the delta time value.
This method should be called once at the start of every frame to calculate the time difference between the current and previous frame.
|
staticprivate |
Stores the current frame's timestamp.
|
staticprivate |
Stores the delta time value in seconds.
|
staticprivate |
The expected duration of each frame.
|
staticprivate |
Stores the previous frame's timestamp.
|
staticprivate |
Stores the program start timestamp.
|
staticprivate |
The target frames per second.