1 #ifndef DONUT_APPLICATION_APPLICATION_HPP
2 #define DONUT_APPLICATION_APPLICATION_HPP
218 return lastSecondFrameCount;
362 using Clock = std::chrono::steady_clock;
364 Clock::duration tickInterval{};
365 Clock::duration minFrameInterval{};
366 Clock::rep maxTicksPerFrame{};
367 Clock::time_point startTime{};
368 Clock::time_point latestFrameTime{};
369 Clock::time_point latestTickProcessingEndTime{};
370 Clock::time_point latestFrameCountTime{};
371 unsigned lastSecondFrameCount = 0u;
372 unsigned frameCounter = 0u;
374 FrameInfo frameInfo{};
375 Clock::duration frameRateLimiterSleepBias{};
376 bool frameRateLimiterSleepEnabled =
false;
377 bool running =
false;
Main application base class.
Definition: Application.hpp:131
virtual ~Application()=default
Virtual destructor which must be overridden by the concrete application class in order to perform any...
unsigned getLastSecondFrameCount() const noexcept
Get the number of frames displayed during the last measured second of the application's run time,...
Definition: Application.hpp:217
virtual void quit()
Initiate the shutdown process, meaning that the current frame will be the last to be processed and di...
void setFrameRateLimiterSleepEnabled(bool frameRateLimiterSleepEnabled)
Enable or disable frame rate limiter sleep.
virtual void update(FrameInfo frameInfo)
Per-frame update callback, called in the main loop once at the beginning of each frame,...
Definition: Application.hpp:304
FrameInfo getLatestFrameInfo() const noexcept
Get information about the latest frame.
Definition: Application.hpp:277
void setFrameRateParameters(float tickRate, float minFrameRate, float maxFrameRate)
Set the frame rate parameters of the application.
TickInfo getLatestTickInfo() const noexcept
Get information about the latest tick.
Definition: Application.hpp:268
virtual void tick(TickInfo tickInfo)
Fixed-rate tick callback, called in the main loop 0 or more times during tick processing,...
Definition: Application.hpp:328
void setFrameRateLimiterSleepBias(std::chrono::steady_clock::duration frameRateLimiterSleepBias)
Set the frame rate limiter sleep bias.
virtual void display(TickInfo tickInfo, FrameInfo frameInfo)
Frame rendering callback, called in the main loop once at the end of each frame after processing tick...
Definition: Application.hpp:354
void run()
Start the main loop of the application and keep running until the application quits or an unhandled e...
bool isRunning() const noexcept
Check if the application is currently running, meaning that it is fully initialized,...
Definition: Application.hpp:197
Application(const ApplicationOptions &options={})
Construct the base of the main application.
Definition: Application.hpp:9
Configuration options for an Application.
Definition: Application.hpp:14
float maxFrameRate
Maximum frame rate of the application, in hertz (frames per second), before frames are delayed.
Definition: Application.hpp:74
float minFrameRate
Minimum frame rate of the application, in hertz (frames per second), before tick slowdown occurs.
Definition: Application.hpp:59
float tickRate
The tick rate of the application, in hertz (ticks per second).
Definition: Application.hpp:39
std::chrono::steady_clock::duration frameRateLimiterSleepBias
The duration offset to subtract from the requested wake-up time when frame rate limiter sleep is enab...
Definition: Application.hpp:114
bool frameRateLimiterSleepEnabled
Put the thread that is running the application to sleep until the next frame is supposed to begin if ...
Definition: Application.hpp:88
Transient information about the current frame of an Application.
Definition: FrameInfo.hpp:11
Transient information about the current tick of an Application.
Definition: TickInfo.hpp:13