|
Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
|
Manages a single threaded, automatically balancing application lifetime. More...
#include <foray_renderloop.hpp>
Classes | |
| struct | FrameTime |
| struct | FrameTimeAnalysis |
| Analysis. More... | |
| struct | RenderInfo |
Public Types | |
| using | InitFunctionPointer = std::function< void()> |
| Function pointer for application initialization. | |
| using | RenderFunctionPointer = std::function< void(RenderInfo &)> |
| Function pointer for a single frame render action. Param#0 : Delta time in seconds. | |
| using | RenderReadyFunctionPointer = std::function< bool()> |
| Function pointer for the RenderLoop to check if application is ready to render next frame. Return true if ready. | |
| using | DestroyFunctionPointer = std::function< void()> |
| Function pointer for application finalization. | |
| using | PollEventsFunctionPointer = std::function< void()> |
| Function pointer for system event polling and handling. | |
| using | OnStateChangedFunctionPointer = std::function< void(ELifetimeState, ELifetimeState)> |
| Function pointer for a callback when the renderloops state changes. Param#0: Old state Param#1: Next state. | |
Public Member Functions | |
| RenderLoop ()=default | |
| RenderLoop (InitFunctionPointer initFunc, RenderFunctionPointer renderFunc, RenderReadyFunctionPointer renderReadyFunc, DestroyFunctionPointer destroyFunc, PollEventsFunctionPointer pollEventsFunc, OnStateChangedFunctionPointer onStateChangedFunc) | |
| Constructor. | |
| int32_t | Run () |
| Runs the application through its full lifetime, invoking all function pointers which have been set. | |
| void | RequestStop (int32_t runResult=0) |
| Request the finalization of the application as soon as possible. | |
| bool | IsRunning () const |
| Returns true, if the internal state is ELifetimeState::Running; false otherwise. | |
| FrameTimeAnalysis | AnalyseFrameTimes () const |
| Analyse all stored frame times. Note: MaxFrameTimeAge member determines maximum possible frame time age. | |
| void | GetFrameTimes (std::vector< fp32_t > &outFrameTimes) const |
| Get all stored frame times (in seconds) by pushing them on the vector. | |
| RenderLoop & | SetInitFunc (InitFunctionPointer func) |
| RenderLoop & | SetRenderFunc (RenderFunctionPointer func) |
| RenderLoop & | SetRenderReadyFunc (RenderReadyFunctionPointer func) |
| RenderLoop & | SetDestroyFunc (DestroyFunctionPointer func) |
| RenderLoop & | SetPollEventsFunc (PollEventsFunctionPointer func) |
| RenderLoop & | SetOnStateChangedFunc (OnStateChangedFunctionPointer func) |
Protected Member Functions | |
| void | AdvanceState () |
Protected Attributes | |
| InitFunctionPointer | mInitFunc = nullptr |
| RenderFunctionPointer | mRenderFunc = nullptr |
| RenderReadyFunctionPointer | mRenderReadyFunc = nullptr |
| DestroyFunctionPointer | mDestroyFunc = nullptr |
| PollEventsFunctionPointer | mPollEventsFunc = nullptr |
| OnStateChangedFunctionPointer | mOnStateChangedFunc = nullptr |
| ELifetimeState | mState = ELifetimeState::PreInit |
| int32_t | mRunResult = 0 |
| AppFrameTiming | mFrameTiming |
| uint64_t | mRenderedFrameCount = 0 |
| std::list< FrameTime > | mFrameTimes |
| fp32_t | mMaxFrameTimeAge = 1.f |
Manages a single threaded, automatically balancing application lifetime.
| using foray::base::RenderLoop::DestroyFunctionPointer = std::function<void()> |
Function pointer for application finalization.
| using foray::base::RenderLoop::InitFunctionPointer = std::function<void()> |
Function pointer for application initialization.
| using foray::base::RenderLoop::OnStateChangedFunctionPointer = std::function<void(ELifetimeState, ELifetimeState)> |
Function pointer for a callback when the renderloops state changes. Param#0: Old state Param#1: Next state.
| using foray::base::RenderLoop::PollEventsFunctionPointer = std::function<void()> |
Function pointer for system event polling and handling.
| using foray::base::RenderLoop::RenderFunctionPointer = std::function<void(RenderInfo&)> |
Function pointer for a single frame render action. Param#0 : Delta time in seconds.
| using foray::base::RenderLoop::RenderReadyFunctionPointer = std::function<bool()> |
Function pointer for the RenderLoop to check if application is ready to render next frame. Return true if ready.
|
inlinedefault |
|
inline |
Constructor.
| initFunc | Function called once to initialize the application |
| renderFunc | Function called once per frame to render the application |
| renderReadyFunc | Function called 1...x times per frame to check if the application is ready for the next frame |
| destroyFunc | Function called once to destroy application resources |
| pollEventsFunc | Function called 1...x times per frame to poll and handle system events |
| onStateChangedFunc | Function called everytime the renderloop state changes |
|
protected |
| FrameTimeAnalysis foray::base::RenderLoop::AnalyseFrameTimes | ( | ) | const |
Analyse all stored frame times. Note: MaxFrameTimeAge member determines maximum possible frame time age.
| void foray::base::RenderLoop::GetFrameTimes | ( | std::vector< fp32_t > & | outFrameTimes | ) | const |
Get all stored frame times (in seconds) by pushing them on the vector.
| bool foray::base::RenderLoop::IsRunning | ( | ) | const |
Returns true, if the internal state is ELifetimeState::Running; false otherwise.
| void foray::base::RenderLoop::RequestStop | ( | int32_t | runResult = 0 | ) |
Request the finalization of the application as soon as possible.
| runResult | The result the encompassing Run() call should return |
| int32_t foray::base::RenderLoop::Run | ( | ) |
Runs the application through its full lifetime, invoking all function pointers which have been set.
| RenderLoop & foray::base::RenderLoop::SetDestroyFunc | ( | DestroyFunctionPointer | func | ) |
| RenderLoop & foray::base::RenderLoop::SetInitFunc | ( | InitFunctionPointer | func | ) |
| RenderLoop & foray::base::RenderLoop::SetOnStateChangedFunc | ( | OnStateChangedFunctionPointer | func | ) |
| RenderLoop & foray::base::RenderLoop::SetPollEventsFunc | ( | PollEventsFunctionPointer | func | ) |
| RenderLoop & foray::base::RenderLoop::SetRenderFunc | ( | RenderFunctionPointer | func | ) |
| RenderLoop & foray::base::RenderLoop::SetRenderReadyFunc | ( | RenderReadyFunctionPointer | func | ) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |