class Time

Inherits: Module<Time>

Manages global time related functionality.

Public

Constructors

Time

Time()

Methods

~Time

~Time() noexcept

GetRealTimeInSeconds

float GetRealTimeInSeconds() const

Gets the time elapsed since application start.

Only gets updated once per frame.

Returns: The time since application start, in seconds. This is real time, unaffected by simulation time scale.

GetRealTimeInMilliseconds

u64 GetRealTimeInMilliseconds() const

Gets the time elapsed since application start.

Only gets updated once per frame.

Returns: The time since application start, in miliseconds. This is real time, unaffected by simulation time scale.

GetFrameDelta

float GetFrameDelta() const

Gets the time since last frame was executed.

Only gets updated once per frame.

Returns: Time since last frame was executed, in seconds.

GetLastFrameTime

float GetLastFrameTime() const

Returns the time (in seconds) the latest frame has started.

GetCurrentFrameIndex

u64 GetCurrentFrameIndex() const

Returns the sequential index of the current frame.

First frame is 0.

Returns: The current frame.

GetTimePrecise

u64 GetTimePrecise() const

Returns the precise time since application start, in microseconds.

Unlike other time methods this is not only updated every frame, but will return exact time at the moment it is called.

Returns: Time in microseconds.

GetStartTimeMs

u64 GetStartTimeMs() const

Gets the time at which the application was started, counting from system start.

Returns: The time since system to application start, in milliseconds.

GetCurrentDateTimeString

String GetCurrentDateTimeString(bool isUTC)

Gets the current date and time in textual form.

isUTC
Outputs the date and time in Coordinated Universal Time, otherwise in local time.

Returns: A String containing the current date and time.

GetCurrentTimeString

String GetCurrentTimeString(bool isUTC)

Gets the current time in textual form

isUTC
Outputs the time in Coordinated Universal Time, otherwise in local time.

Returns: A String containing the current time.

GetAppStartUpDateString

String GetAppStartUpDateString(bool isUTC)

Gets the date and time where the application has been started in textual form.

isUTC
Outputs the date and time in Coordinated Universal Time, otherwise in local time.

Returns: A String containing the application startup date and time.

SetFixedDeltaTime

void SetFixedDeltaTime(float deltaSeconds)

Sets a fixed delta time for deterministic simulation.

When enabled, GetFrameDelta() returns this constant value regardless of real-time elapsed.

deltaSeconds
Fixed time step in seconds (e.g., 0.016666 for 60 FPS). 0 disables.

GetFixedDeltaTimeUs

u64 GetFixedDeltaTimeUs() const

Returns the fixed delta time in microseconds, or 0 if using real-time.

staticInstance

static T &Instance()

Returns a reference to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticInstancePtr

static T *InstancePtr()

Returns a pointer to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticShutDown

static void ShutDown()

Shuts down this module and frees any resources it is using.

staticIsStarted

static bool IsStarted()

Query if the module has been started.

Internal

Methods

Update

void Update()

Called every frame.

Should only be called by Application.

Protected

Methods

~Module<T>

virtual ~Module<T>() = default

OnStartUp

virtual void OnStartUp()

Override if you want your module to be notified once it has been constructed and started.

OnShutDown

virtual void OnShutDown()

Override if you want your module to be notified just before it is deleted.

staticInstanceInternal

static T *&InstanceInternal()

Returns a singleton instance of this module.

staticIsDestroyed

static bool &IsDestroyed()

Checks has the Module been shut down.

staticIsStartedUp

static bool &IsStartedUp()

Checks has the Module been started up.

Private

Fields

mFrameDelta

float mFrameDelta

Frame delta in seconds

mTimeSinceStart

float mTimeSinceStart

Time since start in seconds

mTimeSinceStartMs

u64 mTimeSinceStartMs

mFirstFrame

bool mFirstFrame

mFixedDeltaTimeMicrosec

u64 mFixedDeltaTimeMicrosec

Fixed delta time in microseconds (0 = disabled, use real-time)

mAppStartTime

u64 mAppStartTime

Time the application started, in microseconds

mLastFrameTime

u64 mLastFrameTime

Time since last runOneFrame call, In microseconds

mCurrentFrame

std::atomic<unsigned long> mCurrentFrame

mAppStartUpDate

std::time_t mAppStartUpDate

mTimer

Timer * mTimer