2#include "../foray_basics.hpp"
Controls an apps render scheduling timing.
Definition foray_renderloop.hpp:25
void DisableFpsLimit()
Disables the Fps limit.
Definition foray_renderloop.hpp:39
fp32_t mSecondsPerFrame
Definition foray_renderloop.hpp:42
void SetFramesPerSecond(float value)
Set the target render calls per second.
Definition foray_renderloop.hpp:28
float GetFramesPerSecond() const
Gets target frames per second.
Definition foray_renderloop.hpp:32
void SetSecondsPerFrame(float value)
Set the target time per frame.
Definition foray_renderloop.hpp:30
void Set60Fps()
Sets the target Fps to 60 (0.166667 seconds per frame)
Definition foray_renderloop.hpp:37
float GetSecondsPerFrame() const
Gets target seconds per frame.
Definition foray_renderloop.hpp:34
Manages a single threaded, automatically balancing application lifetime.
Definition foray_renderloop.hpp:47
RenderLoop & SetInitFunc(InitFunctionPointer func)
RenderLoop & SetRenderReadyFunc(RenderReadyFunctionPointer func)
RenderLoop & SetRenderFunc(RenderFunctionPointer func)
DestroyFunctionPointer mDestroyFunc
Definition foray_renderloop.hpp:138
RenderReadyFunctionPointer mRenderReadyFunc
Definition foray_renderloop.hpp:137
std::function< void(RenderInfo &)> RenderFunctionPointer
Function pointer for a single frame render action. Param#0 : Delta time in seconds.
Definition foray_renderloop.hpp:60
FrameTimeAnalysis AnalyseFrameTimes() const
Analyse all stored frame times. Note: MaxFrameTimeAge member determines maximum possible frame time a...
RenderLoop & SetDestroyFunc(DestroyFunctionPointer func)
void GetFrameTimes(std::vector< fp32_t > &outFrameTimes) const
Get all stored frame times (in seconds) by pushing them on the vector.
PollEventsFunctionPointer mPollEventsFunc
Definition foray_renderloop.hpp:139
RenderLoop & SetPollEventsFunc(PollEventsFunctionPointer func)
ELifetimeState mState
Definition foray_renderloop.hpp:142
bool IsRunning() const
Returns true, if the internal state is ELifetimeState::Running; false otherwise.
fp32_t mMaxFrameTimeAge
Definition foray_renderloop.hpp:156
uint64_t mRenderedFrameCount
Definition foray_renderloop.hpp:146
void RequestStop(int32_t runResult=0)
Request the finalization of the application as soon as possible.
InitFunctionPointer mInitFunc
Definition foray_renderloop.hpp:135
std::function< void()> DestroyFunctionPointer
Function pointer for application finalization.
Definition foray_renderloop.hpp:64
int32_t Run()
Runs the application through its full lifetime, invoking all function pointers which have been set.
OnStateChangedFunctionPointer mOnStateChangedFunc
Definition foray_renderloop.hpp:140
int32_t mRunResult
Definition foray_renderloop.hpp:143
std::function< void()> InitFunctionPointer
Function pointer for application initialization.
Definition foray_renderloop.hpp:58
std::function< void()> PollEventsFunctionPointer
Function pointer for system event polling and handling.
Definition foray_renderloop.hpp:66
std::function< void(ELifetimeState, ELifetimeState)> OnStateChangedFunctionPointer
Function pointer for a callback when the renderloops state changes. Param#0: Old state Param#1: Next ...
Definition foray_renderloop.hpp:68
RenderLoop(InitFunctionPointer initFunc, RenderFunctionPointer renderFunc, RenderReadyFunctionPointer renderReadyFunc, DestroyFunctionPointer destroyFunc, PollEventsFunctionPointer pollEventsFunc, OnStateChangedFunctionPointer onStateChangedFunc)
Constructor.
Definition foray_renderloop.hpp:78
std::list< FrameTime > mFrameTimes
Definition foray_renderloop.hpp:155
RenderLoop & SetOnStateChangedFunc(OnStateChangedFunctionPointer func)
std::function< bool()> RenderReadyFunctionPointer
Function pointer for the RenderLoop to check if application is ready to render next frame....
Definition foray_renderloop.hpp:62
RenderFunctionPointer mRenderFunc
Definition foray_renderloop.hpp:136
AppFrameTiming mFrameTiming
Definition foray_renderloop.hpp:145
#define FORAY_GETTER_V(member)
Return value.
Definition foray_basics.hpp:39
#define FORAY_GETTER_MR(member)
Return mutable reference.
Definition foray_basics.hpp:54
#define FORAY_PROPERTY_V(member)
Getter+Setter shorthand for value types.
Definition foray_basics.hpp:81
Definition foray_base_declares.hpp:3
void PrintStateChange(ELifetimeState oldState, ELifetimeState newState)
ELifetimeState
The lifetime states an application progresses through chronologically.
Definition foray_renderloop.hpp:12
float fp32_t
stdint.h style 32 bit floating point type alias (float)
Definition foray_basics.hpp:13
double fp64_t
stdint.h style 64 bit floating point type alias (double)
Definition foray_basics.hpp:15
Analysis.
Definition foray_renderloop.hpp:102
fp32_t MaxFrameTime
Maximum frame time in seconds recorded.
Definition foray_renderloop.hpp:110
fp32_t MinFrameTime
Minimum frame time in seconds recorded.
Definition foray_renderloop.hpp:108
fp32_t TotalTime
Total time in seconds of the analyzed frametimes.
Definition foray_renderloop.hpp:104
uint32_t Count
Count of frametimes analyzed.
Definition foray_renderloop.hpp:106
fp32_t AvgFrameTime
Average frame time in seconds recorded.
Definition foray_renderloop.hpp:112
Definition foray_renderloop.hpp:150
fp64_t Timestamp
Definition foray_renderloop.hpp:152
fp32_t Delta
Definition foray_renderloop.hpp:151
Definition foray_renderloop.hpp:50
fp32_t TargetDelta
Definition foray_renderloop.hpp:52
fp64_t SinceStart
Definition foray_renderloop.hpp:54
fp32_t Delta
Definition foray_renderloop.hpp:51
uint64_t LoopFrameNumber
Definition foray_renderloop.hpp:53