Wasabi
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
WRenderTarget Class Reference

#include <WRenderTarget.hpp>

Inheritance diagram for WRenderTarget:
WBase

Public Member Functions

virtual std::string GetTypeName () const override
 
virtual void SetID (uint32_t newID) override
 
virtual void SetName (std::string newName) override
 
WError Create (uint32_t width, uint32_t height, class WImage *target, class WImage *depth=nullptr)
 
WError Create (uint32_t width, uint32_t height, vector< class WImage * > targets, class WImage *depth=nullptr)
 
WError Create (uint32_t width, uint32_t height, VkImageView *views, uint32_t numViews, VkFormat colorFormat, VkFormat depthFormat)
 
WError Begin ()
 
WError End (bool bSubmit=true)
 
WError Submit (VkSubmitInfo custom_info={})
 
void SetClearColor (WColor col, uint32_t index=0)
 
void SetCamera (class WCamera *cam)
 
VkRenderPass GetRenderPass () const
 
VkPipelineCache GetPipelineCache () const
 
VkCommandBuffer GetCommnadBuffer () const
 
int GetNumColorOutputs () const
 
bool HasDepthOutput () const
 
class WCameraGetCamera () const
 
virtual bool Valid () const override
 
- Public Member Functions inherited from WBase
 WBase (class Wasabi *const app, uint32_t ID=0)
 
uint32_t GetID () const
 
std::string GetName () const
 
class WasabiGetAppPtr () const
 
void AddReference ()
 
void RemoveReference ()
 

Static Public Member Functions

static std::string _GetTypeName ()
 

Protected Member Functions

 WRenderTarget (Wasabi *const app, uint32_t ID=0)
 

Friends

class WRenderTargetManager
 

Additional Inherited Members

- Protected Attributes inherited from WBase
class Wasabim_app
 
uint32_t m_ID
 
std::string m_name
 

Detailed Description

This class represents a render target, which can be used to render things onto. A render target may be backed by a WImage, in which case any rendering that happens on the render target will be reflected on that image, which can then be used normally.

Member Function Documentation

◆ _GetTypeName()

static std::string WRenderTarget::_GetTypeName ( )
static

Returns "RenderTarget" string.

Returns
Returns "RenderTarget" string

◆ Begin()

WError WRenderTarget::Begin ( )

Begin recording renders on this render target.

Returns
Error code, see WError.h

◆ Create() [1/3]

WError WRenderTarget::Create ( uint32_t  width,
uint32_t  height,
class WImage target,
class WImage depth = nullptr 
)

Create a render target with a single color attachment backed by a WImage. The format of the render target attachment will match that of the WImage. Iif bDepth == true, the created render target will have an attachment for depth. This function will cause exactly one frame buffer to be created.

Examples:

rtImg = new WImage(this);
char* pixels = new char[640 * 480 * 4];
rtImg->CreateFromPixelsArray(pixels, 640, 480, false,
4, VK_FORMAT_R8G8B8A8_UNORM, 1);
delete[] pixels;
rt = new WRenderTarget(this);
rt->Create(640, 480, rtImg);
Parameters
widthWidth of the render target
heightHeight of the render target
targetA pointer to a WImage backing the render target
depthA WImage backing the created depth attachment (can be null)
Returns
Error code, see WError.h

◆ Create() [2/3]

WError WRenderTarget::Create ( uint32_t  width,
uint32_t  height,
vector< class WImage * >  targets,
class WImage depth = nullptr 
)

Create a render target with a multiple color attachments, each backed by a WImage. The format of the render target attachments will match those of the WImage's. Iif bDepth == true, the created render target will also have an attachment for depth. This function will cause exactly one frame buffer to be created.

Parameters
widthWidth of the render target
heightHeight of the render target
targetsAn array of WImage's backing the created render target attachments
depthA WImage backing the created depth attachment (can be null)
Returns
Error code, see WError.h

◆ Create() [3/3]

WError WRenderTarget::Create ( uint32_t  width,
uint32_t  height,
VkImageView *  views,
uint32_t  numViews,
VkFormat  colorFormat,
VkFormat  depthFormat 
)

Create a render target backed by VkImageViews (such as the frame buffer). This render target will have 1 attachment for color and one attachment for depth. This function will create as many frame buffers as num_views.

Parameters
widthWidth of the render target
heightHeight of the render target
viewsAn array of VkImageViews to back the render target
numViewsNumber of views in views
colorFormatColor format for the render target
depthFormatDepth format for the render target
Returns
Error code, see WError.h

◆ End()

WError WRenderTarget::End ( bool  bSubmit = true)

End recording renders on this render target. If bSubmit is set to false, you have to call Submit() afterwards to actually perform the rendering.

Parameters
bSubmitWhen set to true, recorded renders will be submitted to the Vulkan graphics queue and thus will be reflected on the backing WImage of VkImageViews
Returns
Error code, see WError.h

◆ GetCamera()

class WCamera* WRenderTarget::GetCamera ( ) const

Retrieve the camera for this render target.

Returns
Pointer to the camera of this render target

◆ GetCommnadBuffer()

VkCommandBuffer WRenderTarget::GetCommnadBuffer ( ) const

Retrieves the command buffer onto which rendering should occur to happen on this render target.

Returns
Handle of the rendering command buffer for this render target

◆ GetNumColorOutputs()

int WRenderTarget::GetNumColorOutputs ( ) const

Retrieves the number of color output attachments.

Returns
The number of color output attachments

◆ GetPipelineCache()

VkPipelineCache WRenderTarget::GetPipelineCache ( ) const

Retrieves the pipeline cache associated with this render target.

Returns
Handle of the pipeline cache for this render target

◆ GetRenderPass()

VkRenderPass WRenderTarget::GetRenderPass ( ) const

Retrieves the render pass associated with this render target.

Returns
Handle of the render pass for this render target

◆ GetTypeName()

virtual std::string WRenderTarget::GetTypeName ( ) const
overridevirtual

This function must be implemented by a child class. This is used for debugging, in which a class should return its name.

Returns
The name of the class

Implements WBase.

◆ HasDepthOutput()

bool WRenderTarget::HasDepthOutput ( ) const

Checks whether or not the render target has a depth attachment.

Returns
True if the render target has a depth attachment, false otherwise

◆ SetCamera()

void WRenderTarget::SetCamera ( class WCamera cam)

Sets the camera that will be used when things are rendered using this render target.

Parameters
camCamera to use

◆ SetClearColor()

void WRenderTarget::SetClearColor ( WColor  col,
uint32_t  index = 0 
)

Sets the color to use when the render target is cleared upon calling Begin().

Parameters
colClear color to use
indexAttachment index (as supplied to Create()). The depth target attachment index is the last one (so if this render target has 1 color attachment and one depth attachment, they will have indices 0 and 1 respectively) and the clear value of the depth attachment will only use the red component of the supplied WColor (the stencil will be green component)

◆ SetID()

virtual void WRenderTarget::SetID ( uint32_t  newID)
overridevirtual

Sets the ID of this object and notifies its manager.

Parameters
newIDNew ID

Implements WBase.

◆ SetName()

virtual void WRenderTarget::SetName ( std::string  newName)
overridevirtual

Sets the name of this object.

Parameters
nameNew name for the object

Implements WBase.

◆ Submit()

WError WRenderTarget::Submit ( VkSubmitInfo  custom_info = {})

Submit the command queue (generated between a call to Begin() and End()) to be performed by Vulkan. @params custom_info Optional custom VkSubmitInfo structure passed to vkQueueSubmit, this will be filled automatically if you ignore this argument (or pass a VkSubmitInfo with pCommandBuffers = NULL. Normally, you should fill pCommandBuffers with GetCommnadBuffer()

Returns
Error code, see WError.h

◆ Valid()

virtual bool WRenderTarget::Valid ( ) const
overridevirtual

Checks the validity of this render target. A render target is valid when it has at least one frame buffer.

Returns
true if the render target is valid, false otherwise

Implements WBase.


The documentation for this class was generated from the following file:
WRenderTarget
Definition: WRenderTarget.hpp:31
WImage
Definition: WImage.hpp:47