AppLoopManager
Manages the main application loop timing, including frame rate limiting and vertical sync status. More...
#include "Core/AppLoopManager.h"
Public Functions
Name | |
---|---|
AppLoopManager()<br>Default constructor. | |
AppLoopManager(bool vsync, bool shouldLimitFPS, int targetFPS, bool shouldLimitFPSOnIdle, int targetFPSOnIdle, int secondsBeforeIdle)<br>Parameterized constructor. | |
~AppLoopManager()<br>Destructor. | |
void | enableFPSLimit(bool enable)<br>Enables or disables active FPS limiting. |
double | getDeltaTime() const<br>Retrieves the time elapsed during the last frame. |
double | getFrameDurationOnIdle()<br>Calculates time remaining until next idle frame. |
int | getSecondsBeforeIdle() const<br>Gets the number of seconds before idle frame limiting kicks in. |
int | getTargetFPS() const<br>Gets the current target FPS for active mode. |
int | getTargetFPSOnIdle() const<br>Gets the current target FPS for idle mode. |
bool | isVsync() const<br>Returns whether vertical sync is enabled. |
void | setSecondsBeforeIdle(int seconds)<br>Sets the number of seconds before idle frame limiting kicks in. |
void | setShouldLimitFPSOnIdle(bool enable)<br>Enables or disables idle FPS limiting. |
void | setTargetFPS(int fps)<br>Sets a new target FPS for active mode. |
void | setTargetFPSOnIdle(int fps)<br>Sets a new target FPS for idle mode. |
void | setVSync(bool enable)<br>Set VSync status, does not affect on real vsync settings. |
bool | shouldLimitFPS() const<br>Checks if active frame limiting is engaged. |
bool | shouldLimitFPSOnIdle() const<br>Checks if idle frame limiting is enabled. |
void | sleepForNextFrame()<br>Sleeps for the remaining time until the next frame. |
void | sleepUntilNextFrame()<br>Sleeps until the next scheduled frame time. |
void | startFrame()<br>Marks the start of a new frame. |
Detailed Description
class AppLoopManager;
class AppLoopManager;
Manages the main application loop timing, including frame rate limiting and vertical sync status.
Provides methods to start frames, sleep until or for the next frame, and adjust timing parameters such as target FPS for active and idle modes.
Public Functions Documentation
function AppLoopManager
AppLoopManager()
AppLoopManager()
Default constructor.
Initializes manager with default settings (VSync enabled, 60 FPS active, 20 FPS idle).
function AppLoopManager
AppLoopManager(
bool vsync,
bool shouldLimitFPS,
int targetFPS,
bool shouldLimitFPSOnIdle,
int targetFPSOnIdle,
int secondsBeforeIdle
)
AppLoopManager(
bool vsync,
bool shouldLimitFPS,
int targetFPS,
bool shouldLimitFPSOnIdle,
int targetFPSOnIdle,
int secondsBeforeIdle
)
Parameterized constructor.
Parameters:
- vsync Enable (true) or disable (false) vertical synchronization.
- shouldLimitFPS Enable (true) or disable (false) active frame rate limiting.
- targetFPS Target frames per second when active.
- shouldLimitFPSOnIdle Enable (true) or disable (false) idle frame rate limiting.
- targetFPSOnIdle Target frames per second when idle.
- secondsBeforeIdle Seconds before idle frame limiting kicks in.
Creates manager with custom vsync and frame rate limiting settings.
function ~AppLoopManager
~AppLoopManager()
~AppLoopManager()
Destructor.
Cleans up any platform-specific timing settings.
function enableFPSLimit
inline void enableFPSLimit(
bool enable
)
inline void enableFPSLimit(
bool enable
)
Enables or disables active FPS limiting.
Parameters:
- enable true to enable limiting, false to disable.
function getDeltaTime
inline double getDeltaTime() const
inline double getDeltaTime() const
Retrieves the time elapsed during the last frame.
Return: Delta time in seconds.
function getFrameDurationOnIdle
double getFrameDurationOnIdle()
double getFrameDurationOnIdle()
Calculates time remaining until next idle frame.
Return: Seconds until next idle frame, or 0.0 if limiting is disabled or overdue.
Updates internal timestamp and returns remaining seconds.
function getSecondsBeforeIdle
inline int getSecondsBeforeIdle() const
inline int getSecondsBeforeIdle() const
Gets the number of seconds before idle frame limiting kicks in.
Return: Seconds before idle limiting starts.
function getTargetFPS
inline int getTargetFPS() const
inline int getTargetFPS() const
Gets the current target FPS for active mode.
Return: Active mode frames per second.
function getTargetFPSOnIdle
inline int getTargetFPSOnIdle() const
inline int getTargetFPSOnIdle() const
Gets the current target FPS for idle mode.
Return: Idle mode frames per second.
function isVsync
inline bool isVsync() const
inline bool isVsync() const
Returns whether vertical sync is enabled.
Return: true if VSync is enabled, false otherwise.
function setSecondsBeforeIdle
void setSecondsBeforeIdle(
int seconds
)
void setSecondsBeforeIdle(
int seconds
)
Sets the number of seconds before idle frame limiting kicks in.
Parameters:
- seconds Number of seconds before idle limiting starts.
function setShouldLimitFPSOnIdle
inline void setShouldLimitFPSOnIdle(
bool enable
)
inline void setShouldLimitFPSOnIdle(
bool enable
)
Enables or disables idle FPS limiting.
Parameters:
- enable true to enable, false to disable.
function setTargetFPS
void setTargetFPS(
int fps
)
void setTargetFPS(
int fps
)
Sets a new target FPS for active mode.
Parameters:
- fps Desired active FPS.
function setTargetFPSOnIdle
void setTargetFPSOnIdle(
int fps
)
void setTargetFPSOnIdle(
int fps
)
Sets a new target FPS for idle mode.
Parameters:
- fps Desired idle FPS.
function setVSync
inline void setVSync(
bool enable
)
inline void setVSync(
bool enable
)
Set VSync status, does not affect on real vsync settings.
Parameters:
- enable true to set enable VSync status, false to disable.
function shouldLimitFPS
inline bool shouldLimitFPS() const
inline bool shouldLimitFPS() const
Checks if active frame limiting is engaged.
Return: true if FPS limiting is enabled and VSync is off.
function shouldLimitFPSOnIdle
inline bool shouldLimitFPSOnIdle() const
inline bool shouldLimitFPSOnIdle() const
Checks if idle frame limiting is enabled.
Return: true if idle FPS limiting is enabled.
function sleepForNextFrame
void sleepForNextFrame()
void sleepForNextFrame()
Sleeps for the remaining time until the next frame.
Uses sleep_for and corrects for any timing drift.
function sleepUntilNextFrame
void sleepUntilNextFrame()
void sleepUntilNextFrame()
Sleeps until the next scheduled frame time.
Uses sleep_until and adjusts the next frame timestamp to maintain a consistent frame rate.
function startFrame
void startFrame()
void startFrame()
Marks the start of a new frame.
Updates m_deltaTime
to the elapsed time since the last frame.
Updated on 2025-05-31 at 12:55:30 +0000