Castor3D 0.12.0
Multiplatform 3D engine
Classes | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
castor3d::RenderLoop Class Referenceabstract

#include <RenderLoop.hpp>

Inheritance diagram for castor3d::RenderLoop:
Inheritance graph
[legend]
Collaboration diagram for castor3d::RenderLoop:
Collaboration graph
[legend]

Classes

struct  UploadResources
 

Public Member Functions

C3D_API RenderLoop (Engine &engine, uint32_t wantedFPS, bool isAsync)
 Constructor. More...
 
virtual C3D_API ~RenderLoop ()
 Destructor. More...
 
C3D_API void cleanup ()
 Cleans up the render loop. More...
 
C3D_API void showDebugOverlays (bool show)
 Show or hide debug overlays. More...
 
virtual C3D_API void enableVSync (bool enable)
 Updates the V-Sync status. More...
 
C3D_API void flushEvents ()
 Flushs all events of all frame listeners. More...
 
C3D_API uint32_t registerTimer (castor::String const &category, FramePassTimer &timer)
 Registers a render pass timer. More...
 
C3D_API void unregisterTimer (castor::String const &category, FramePassTimer &timer)
 Unregisters a render pass timer. More...
 
C3D_API void registerBuffer (ShaderBuffer const &buffer)
 Registers a ShaderBuffer. More...
 
C3D_API void unregisterBuffer (ShaderBuffer const &buffer)
 Unregisters a ShaderBuffer. More...
 
C3D_API bool hasDebugOverlays () const
 
C3D_API void dumpFrameTimes (Parameters &params) const
 The average frame time, in nanoseconds. More...
 
C3D_API castor::Nanoseconds getAvgFrameTime () const
 
virtual C3D_API void beginRendering ()=0
 Starts threaded render loop. More...
 
virtual C3D_API void renderSyncFrame (castor::Milliseconds tslf=0_ms)=0
 Renders one frame, only if not in render loop. More...
 
virtual C3D_API void pause ()=0
 Pauses the render loop. More...
 
virtual C3D_API void resume ()=0
 Resumes the render loop. More...
 
virtual C3D_API void endRendering ()=0
 Ends the render, cleans upĀ engine. More...
 
castor::Milliseconds getFrameTime () const
 
uint32_t getWantedFps () const
 
castor::Microseconds getLastFrameTime () const
 

Static Public Attributes

static constexpr uint32_t UnlimitedFPS = 0xFFFFFFFFu
 

Protected Member Functions

C3D_API void doRenderFrame (castor::Milliseconds tslf=0_ms)
 Starts threaded render loop. More...
 

Protected Attributes

RenderSystemm_renderSystem
 
uint32_t m_wantedFPS
 
castor::Milliseconds m_frameTime
 
std::atomic< castor::Microseconds > m_lastFrameTime
 
std::unique_ptr< DebugOverlaysm_debugOverlays
 
std::mutex m_debugOverlaysMtx
 
std::array< UploadResources, 2u > m_uploadResources
 
uint32_t m_currentUpdate { 0u }
 
crg::SemaphoreWaitArray m_toWait
 

Constructor & Destructor Documentation

◆ RenderLoop()

C3D_API castor3d::RenderLoop::RenderLoop ( Engine engine,
uint32_t  wantedFPS,
bool  isAsync 
)

Constructor.

Parameters
[in]engineThe engine.
[in]wantedFPSThe wanted FPS count.
[in]isAsyncTells if the render loop is asynchronous.

◆ ~RenderLoop()

virtual C3D_API castor3d::RenderLoop::~RenderLoop ( )
virtual

Destructor.

Member Function Documentation

◆ beginRendering()

virtual C3D_API void castor3d::RenderLoop::beginRendering ( )
pure virtual

Starts threaded render loop.

Implemented in castor3d::RenderLoopAsync, and castor3d::RenderLoopSync.

◆ cleanup()

C3D_API void castor3d::RenderLoop::cleanup ( )

Cleans up the render loop.

◆ doRenderFrame()

C3D_API void castor3d::RenderLoop::doRenderFrame ( castor::Milliseconds  tslf = 0_ms)
protected

Starts threaded render loop.

Parameters
[in]tslfThe time elapsed since last frame.

◆ dumpFrameTimes()

C3D_API void castor3d::RenderLoop::dumpFrameTimes ( Parameters params) const

The average frame time, in nanoseconds.

◆ enableVSync()

virtual C3D_API void castor3d::RenderLoop::enableVSync ( bool  enable)
virtual

Updates the V-Sync status.

Parameters
[in]enableThe status.

Reimplemented in castor3d::RenderLoopAsync.

◆ endRendering()

virtual C3D_API void castor3d::RenderLoop::endRendering ( )
pure virtual

Ends the render, cleans upĀ engine.

Remarks
Ends the threaded render loop, if any.

Implemented in castor3d::RenderLoopAsync, and castor3d::RenderLoopSync.

◆ flushEvents()

C3D_API void castor3d::RenderLoop::flushEvents ( )

Flushs all events of all frame listeners.

◆ getAvgFrameTime()

C3D_API castor::Nanoseconds castor3d::RenderLoop::getAvgFrameTime ( ) const
Returns
The average frame time, in nanoseconds.

◆ getFrameTime()

castor::Milliseconds castor3d::RenderLoop::getFrameTime ( ) const
inline
Returns
The wanted frame time, in milliseconds.

References m_frameTime.

◆ getLastFrameTime()

castor::Microseconds castor3d::RenderLoop::getLastFrameTime ( ) const
inline
Returns
The last frame time, in milliseconds.

References m_lastFrameTime.

◆ getWantedFps()

uint32_t castor3d::RenderLoop::getWantedFps ( ) const
inline
Returns
The wanted refresh rate.

References m_wantedFPS.

◆ hasDebugOverlays()

C3D_API bool castor3d::RenderLoop::hasDebugOverlays ( ) const
Returns
The debug overlays shown status.

◆ pause()

virtual C3D_API void castor3d::RenderLoop::pause ( )
pure virtual

Pauses the render loop.

Implemented in castor3d::RenderLoopAsync, and castor3d::RenderLoopSync.

◆ registerBuffer()

C3D_API void castor3d::RenderLoop::registerBuffer ( ShaderBuffer const &  buffer)

Registers a ShaderBuffer.

Parameters
[in]bufferThe ShaderBuffer.

◆ registerTimer()

C3D_API uint32_t castor3d::RenderLoop::registerTimer ( castor::String const &  category,
FramePassTimer &  timer 
)

Registers a render pass timer.

Parameters
[in]categoryThe timer category name.
[in]timerThe timer to register.
Returns
The query ID.

◆ renderSyncFrame()

virtual C3D_API void castor3d::RenderLoop::renderSyncFrame ( castor::Milliseconds  tslf = 0_ms)
pure virtual

Renders one frame, only if not in render loop.

Parameters
[in]tslfThe time elapsed since last frame.

Implemented in castor3d::RenderLoopAsync, and castor3d::RenderLoopSync.

◆ resume()

virtual C3D_API void castor3d::RenderLoop::resume ( )
pure virtual

Resumes the render loop.

Implemented in castor3d::RenderLoopAsync, and castor3d::RenderLoopSync.

◆ showDebugOverlays()

C3D_API void castor3d::RenderLoop::showDebugOverlays ( bool  show)

Show or hide debug overlays.

Parameters
[in]showThe status.

◆ unregisterBuffer()

C3D_API void castor3d::RenderLoop::unregisterBuffer ( ShaderBuffer const &  buffer)

Unregisters a ShaderBuffer.

Parameters
[in]bufferThe ShaderBuffer.

◆ unregisterTimer()

C3D_API void castor3d::RenderLoop::unregisterTimer ( castor::String const &  category,
FramePassTimer &  timer 
)

Unregisters a render pass timer.

Parameters
[in]categoryThe timer category name.
[in]timerThe timer to unregister.

Member Data Documentation

◆ m_currentUpdate

uint32_t castor3d::RenderLoop::m_currentUpdate { 0u }
protected

◆ m_debugOverlays

std::unique_ptr< DebugOverlays > castor3d::RenderLoop::m_debugOverlays
protected

The debug overlays.

◆ m_debugOverlaysMtx

std::mutex castor3d::RenderLoop::m_debugOverlaysMtx
protected

◆ m_frameTime

castor::Milliseconds castor3d::RenderLoop::m_frameTime
protected

The wanted time for a frame.

Referenced by getFrameTime().

◆ m_lastFrameTime

std::atomic< castor::Microseconds > castor3d::RenderLoop::m_lastFrameTime
protected

The elapsed time for the last frame.

Referenced by getLastFrameTime().

◆ m_renderSystem

RenderSystem& castor3d::RenderLoop::m_renderSystem
protected

The current RenderSystem.

◆ m_toWait

crg::SemaphoreWaitArray castor3d::RenderLoop::m_toWait
protected

◆ m_uploadResources

std::array< UploadResources, 2u > castor3d::RenderLoop::m_uploadResources
protected

◆ m_wantedFPS

uint32_t castor3d::RenderLoop::m_wantedFPS
protected

The wanted FPS, used in threaded render mode.

Referenced by getWantedFps().

◆ UnlimitedFPS

constexpr uint32_t castor3d::RenderLoop::UnlimitedFPS = 0xFFFFFFFFu
staticconstexpr

The documentation for this class was generated from the following file: