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

#include <WSprite.hpp>

Inheritance diagram for WSpriteManager:
WManager< WSprite >

Public Member Functions

 WSpriteManager (class Wasabi *const app)
 
WError Load ()
 
WError Resize (uint32_t width, uint32_t height)
 
WSpriteCreateSprite (class WImage *img=nullptr, uint32_t ID=0) const
 
WSpriteCreateSprite (class WEffect *fx, uint32_t bindingSet, class WImage *img=nullptr, uint32_t ID=0) const
 
class WShaderGetSpriteVertexShader () const
 
class WShaderGetSpritePixelShader () const
 
class WEffectCreateSpriteEffect (class WRenderTarget *rt=nullptr, class WShader *ps=nullptr, VkPipelineColorBlendAttachmentState bs={}, VkPipelineDepthStencilStateCreateInfo dss={}, VkPipelineRasterizationStateCreateInfo rs={}) const
 
- Public Member Functions inherited from WManager< WSprite >
 WManager (class Wasabi *const a)
 
bool RegisterChangeCallback (std::string name, std::function< void(WSprite *, bool)> callback)
 
void RemoveChangeCallback (std::string name)
 
void AddEntity (WSprite *entity)
 
bool RemoveEntity (WSprite *entity)
 
void OnEntityNameChanged (WSprite *entity, std::string oldName)
 
virtual void Init ()
 
WSpriteGetEntity (uint32_t ID) const
 
WSpriteGetEntity (std::string name) const
 
WSpriteGetEntityByIndex (uint32_t index) const
 
uint32_t GetEntitiesCount (void) const
 

Friends

class WSprite
 

Additional Inherited Members

- Public Attributes inherited from WManager< WSprite >
class Wasabi *const m_app
 
- Protected Attributes inherited from WManager< WSprite >
std::vector< WSprite * > m_entities [W_HASHTABLESIZE]
 
std::unordered_map< std::string, WSprite * > m_entitiesByName
 

Detailed Description

Manager class for WSprite.

Member Function Documentation

◆ CreateSprite() [1/2]

WSprite* WSpriteManager::CreateSprite ( class WEffect fx,
uint32_t  bindingSet,
class WImage img = nullptr,
uint32_t  ID = 0 
) const

Allocates and initializes a new sprite. If an image is supplied, it will be set to the default sprite's material texture "diffuseTexture".

Parameters
fxAn effect to be used for this sprite. If nullptr, a default effect will be used
bindingSetThe binding set to use to create the material from the given fx
imgImage to set to the new sprite
IDId of the new image
Returns
New sprite

◆ CreateSprite() [2/2]

WSprite* WSpriteManager::CreateSprite ( class WImage img = nullptr,
uint32_t  ID = 0 
) const

Allocates and initializes a new sprite. If an image is supplied, it will be set to the default sprite's material texture "diffuseTexture".

Parameters
imgImage to set to the new sprite
IDId of the new image
Returns
New sprite

◆ CreateSpriteEffect()

class WEffect* WSpriteManager::CreateSpriteEffect ( class WRenderTarget rt = nullptr,
class WShader ps = nullptr,
VkPipelineColorBlendAttachmentState  bs = {},
VkPipelineDepthStencilStateCreateInfo  dss = {},
VkPipelineRasterizationStateCreateInfo  rs = {} 
) const

Creates a new WEffect using the default sprite vertex shader and a supplied pixel shader and other states

Parameters
rtRender target intended for this effect. If this is null, the render target will be the backbuffer
psA pixel/fragment shader to use. If none is provided, the default pixel shader will be used
bsBlend state to use. If none is provided, the default blend state will be used (do not set .colorWriteMask to 0)
bsDepth/stencil state to use. If none is provided, the default depth/stencil state will be used
bsRasterization state to use. If none is provided, the default rasterization state will be used
Returns
Newly created effect, or nullptr on failure

◆ GetSpritePixelShader()

class WShader* WSpriteManager::GetSpritePixelShader ( ) const

Retrieves the default pixel shader that sprites can use.

Returns
Default pixel shader that sprites can use

◆ GetSpriteVertexShader()

class WShader* WSpriteManager::GetSpriteVertexShader ( ) const

Retrieves the default vertex shader that sprites use.

Returns
Default vertex shader that sprites use

◆ Load()

WError WSpriteManager::Load ( )

Loads the manager and creates the default geometry and material.

Returns
Error code, see WError.h

◆ Resize()

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

Called when the application window is resized.

Parameters
widthNew screen width
heightNew screen height
Returns
Error code, see WError.h

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