Wasabi
Classes | Public Member Functions | Friends | List of all members
WRenderer Class Reference

#include <WRenderer.hpp>

Public Member Functions

 WRenderer (class Wasabi *const app)
 
WError Initialize ()
 
void Render ()
 
void Cleanup ()
 
WError Resize (uint32_t width, uint32_t height)
 
WError SetRenderingStages (std::vector< class WRenderStage * > stages)
 
class WRenderStageGetRenderStage (std::string stageName) const
 
std::string GetSpritesRenderStageName () const
 
std::string GetTextsRenderStageName () const
 
std::string GetParticlesRenderStageName () const
 
std::string GetPickingRenderStageName () const
 
class WRenderTargetGetRenderTarget (std::string stageName="") const
 
class WImageGetRenderTargetImage (std::string imageName) const
 
VulkanSwapChainGetSwapchain () const
 
VkSampler GetTextureSampler (W_TEXTURE_SAMPLER_TYPE type=TEXTURE_SAMPLER_DEFAULT) const
 
VkCommandBuffer GetCurrentPrimaryCommandBuffer () const
 
uint32_t GetCurrentBufferingIndex () const
 
VkQueue GetQueue () const
 

Friends

class Wasabi
 
int RunWasabi (class Wasabi *)
 

Detailed Description

A WRenderer is a base class that can be derived to implement a certain rendering method (e.g. a forward rendering variant or deferred rendering variant). A renderer can be assigned to the engine the same way components are, during the initialization in Wasabi::SetupComponents().

Member Function Documentation

◆ Cleanup()

void WRenderer::Cleanup ( )

Frees all resources allocated by the renderer. This function should be implemented by a child class and it should perform the child-specific cleanup procedure. For a renderer bound to Wasabi, this function will be called before the application closes.

◆ GetCurrentBufferingIndex()

uint32_t WRenderer::GetCurrentBufferingIndex ( ) const

Retrieves the current buffering index. The current buffering index is the index of buffers that should be used for the current frame (safe to assume GPU access to it is done). All memory access to those buffers have to use a memory barriers to ensure no races happen.

◆ GetCurrentPrimaryCommandBuffer()

VkCommandBuffer WRenderer::GetCurrentPrimaryCommandBuffer ( ) const

Retrieves the primary command buffer used in the current frame (should be called within a WRenderStage's render).

Returns
Current primary command buffer for the frame

◆ GetParticlesRenderStageName()

std::string WRenderer::GetParticlesRenderStageName ( ) const
Returns
The name of the particles render stage

◆ GetPickingRenderStageName()

std::string WRenderer::GetPickingRenderStageName ( ) const
Returns
The name of the render stage to use its render target camera for picking

◆ GetQueue()

VkQueue WRenderer::GetQueue ( ) const

Retrieves the currently used Vulkan graphics queue.

Returns
Currently used Vulkan graphics queue

◆ GetRenderStage()

class WRenderStage* WRenderer::GetRenderStage ( std::string  stageName) const

Retrieves a set render stage with a given name.

Parameters
stageNameName of the stage to retrieve
Returns
Render stage requested

◆ GetRenderTarget()

class WRenderTarget* WRenderer::GetRenderTarget ( std::string  stageName = "") const

Retrieves the render target of a given render stage. If stageName is "", this will return the backbuffer's render target, which is always the last

Parameters
stageNameName of the stage, using "" will return the backbuffer's render target
Returns
Pointer to the render target of the given stage

◆ GetRenderTargetImage()

class WImage* WRenderer::GetRenderTargetImage ( std::string  imageName) const

Retrieves a render target output image from a currently set render stage.

Parameters
imageNameName of the image in one of the render stages
Returns
Pointer to the render target image with the given name

◆ GetSpritesRenderStageName()

std::string WRenderer::GetSpritesRenderStageName ( ) const
Returns
The name of the sprites render stage

◆ GetSwapchain()

VulkanSwapChain* WRenderer::GetSwapchain ( ) const

Retrieves the swap chain.

◆ GetTextsRenderStageName()

std::string WRenderer::GetTextsRenderStageName ( ) const
Returns
The name of the text render stage

◆ GetTextureSampler()

VkSampler WRenderer::GetTextureSampler ( W_TEXTURE_SAMPLER_TYPE  type = TEXTURE_SAMPLER_DEFAULT) const

Retrieves a Vulkan image sampler of a given type

Parameters
typeType of the requested sampler
Returns
A handle of a usable Vulkan image sampler

◆ Initialize()

WError WRenderer::Initialize ( )

Initializes the renderer resources. This function should be implemented by a child class and it should initialize the child-specific resources. For a renderer bound to Wasabi, this function will be called during Wasabi's Wasabi::StartEngine() call.

Returns
Error code, see WError.h

◆ Render()

void WRenderer::Render ( )

Begin rendering a frame. This function is responsible for semaphore synchronization and swap chain presentation.

◆ Resize()

WError WRenderer::Resize ( uint32_t  width,
uint32_t  height 
)

Notifies the renderer of a change in screen (window) size. This function could be implemented by a child class to perform child-specific resizing procedures. An overridden implementation may (and probably should) call the WRenderer implementation of resize at some point, which will resize the swap chain and the default render target attached to it.

Parameters
widthNew screen (window) width
heightNew screen (window) height
Returns
Error code, see WError

◆ SetRenderingStages()

WError WRenderer::SetRenderingStages ( std::vector< class WRenderStage * >  stages)

Destroys the previously set render stages and assigns the new ones. This function will call Initialize on all the render stages. Render stages define the sequence of rendering events that happen when each frame is rendered.

Parameters
stagesRender stages to use
Returns
Error code, see WError

Friends And Related Function Documentation

◆ RunWasabi

int RunWasabi ( class Wasabi )
friend

Runs a Wasabi instance. This function blocks until the instance quits. This function will run the message loop and render frames and do everything required to run the engine in the right environment.


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