Muto 0.0.1
Cross-Platform Application Template
GitHub Repo | Muto Updates | Muto's Author
Loading...
Searching...
No Matches
Muto::SubTextureComponent Struct Reference

Component that holds sub-texture data for sprites. More...

#include <Components.h>

Public Member Functions

Ref< SubTexture2D > & GetSubTexture ()
 
 operator const Ref< SubTexture2D > & () const
 
 operator Ref< SubTexture2D > & ()
 
void SetOffset (const glm::vec2 &offset)
 Sets the offset for the sub-texture.
 
void SetTexture (const Ref< Texture2D > &texture)
 Copy constructor.
 
void SetTilingFactor (const glm::vec2 &tiling)
 Sets the tiling factor for the sub-texture.
 
 SubTextureComponent ()=default
 
 SubTextureComponent (const Ref< SubTexture2D > &subTexture)
 Constructor that initializes the sub-texture directly.
 
 SubTextureComponent (const Ref< Texture2D > &texture)
 Constructor that initializes the sub-texture from a full texture.
 

Public Attributes

glm::vec2 Offset = { 0.0f, 0.0f }
 Offset for the sub-texture.
 
Ref< SubTexture2D > SubTexture
 The sub-texture reference.
 
glm::vec2 TilingFactor = { 1.0f, 1.0f }
 Tiling factor for the sub-texture.
 

Detailed Description

Component that holds sub-texture data for sprites.

Constructor & Destructor Documentation

◆ SubTextureComponent() [1/3]

Muto::SubTextureComponent::SubTextureComponent ( )
default

◆ SubTextureComponent() [2/3]

Muto::SubTextureComponent::SubTextureComponent ( const Ref< Texture2D > &  texture)
inline

Constructor that initializes the sub-texture from a full texture.

141 : SubTexture(SubTexture2D::CreateFromCoords(texture, { 0, 0 }, { texture->GetWidth(), texture->GetHeight() })) {
142 }
static Ref< SubTexture2D > CreateFromCoords(const Ref< Texture2D > &texture, const glm::vec2 &coords, const glm::vec2 &cellSize, const glm::vec2 &spriteSize={1, 1})
Creates a SubTexture2D from a grid of cells within the given texture.
Definition SubTexture2D.cpp:17
constexpr Scope< T > CreateScope(Args &&... args)
Creates a Scope (unique_ptr) for the given type and constructor arguments.
Definition Defines_Macros.h:51
Ref< SubTexture2D > SubTexture
The sub-texture reference.
Definition Components.h:130

References SubTextureComponent().

Referenced by SubTextureComponent(), and SubTextureComponent().

◆ SubTextureComponent() [3/3]

Muto::SubTextureComponent::SubTextureComponent ( const Ref< SubTexture2D > &  subTexture)
inline

Constructor that initializes the sub-texture directly.

146 }

References SubTextureComponent().

Member Function Documentation

◆ GetSubTexture()

Ref< SubTexture2D > & Muto::SubTextureComponent::GetSubTexture ( )
inline
164{ return SubTexture; }

◆ operator const Ref< SubTexture2D > &()

Muto::SubTextureComponent::operator const Ref< SubTexture2D > & ( ) const
inline
163{ return SubTexture; }

◆ operator Ref< SubTexture2D > &()

Muto::SubTextureComponent::operator Ref< SubTexture2D > & ( )
inline
162{ return SubTexture; }

◆ SetOffset()

void Muto::SubTextureComponent::SetOffset ( const glm::vec2 &  offset)
inline

Sets the offset for the sub-texture.

158 {
159 Offset = offset;
160 }
glm::vec2 Offset
Offset for the sub-texture.
Definition Components.h:134

◆ SetTexture()

void Muto::SubTextureComponent::SetTexture ( const Ref< Texture2D > &  texture)
inline

Copy constructor.

148 {
149 SubTexture = SubTexture2D::CreateFromCoords(texture, { 0, 0 }, { texture->GetWidth(), texture->GetHeight() });
150 }

◆ SetTilingFactor()

void Muto::SubTextureComponent::SetTilingFactor ( const glm::vec2 &  tiling)
inline

Sets the tiling factor for the sub-texture.

153 {
155 }
glm::vec2 TilingFactor
Tiling factor for the sub-texture.
Definition Components.h:132

Member Data Documentation

◆ Offset

glm::vec2 Muto::SubTextureComponent::Offset = { 0.0f, 0.0f }

Offset for the sub-texture.

134{ 0.0f, 0.0f };

◆ SubTexture

Ref<SubTexture2D> Muto::SubTextureComponent::SubTexture

The sub-texture reference.

◆ TilingFactor

glm::vec2 Muto::SubTextureComponent::TilingFactor = { 1.0f, 1.0f }

Tiling factor for the sub-texture.

132{ 1.0f, 1.0f };

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