CoriEngine
Loading...
Searching...
No Matches
Cori::Graphics::SpriteAtlas Class Reference

Holds the sprite atlas and UVs for sprites in it. All spite atlases are padded, so no sprite atlas bleeding will occur. More...

#include <SpriteAtlas.hpp>

Inheritance diagram for Cori::Graphics::SpriteAtlas:
Collaboration diagram for Cori::Graphics::SpriteAtlas:

Classes

class  Descriptor
 SpriteAtlas Descriptor meant to be used with AssetManager only. More...

Public Member Functions

const UVsGetSpriteUVsAtIndex (uint32_t index) const
 Request the UVs for the spite at specific index.
const UVsGetSpriteUVsAtPosition (glm::u16vec2 pos) const
 Request the UVs for the spite at specific position.
bool GetSuccessStatus () const
 Checks if the SpriteAtlas was created successfully.
std::string_view GetName () const
 Retrieves the name of the SpriteAtlas.
std::shared_ptr< Texture2DGetTexture () const
 Retrieves the Texture2D stored in the SpriteAtlas.

Static Public Member Functions

static std::shared_ptr< SpriteAtlasCreate (std::string name, const std::shared_ptr< Image > &image, const glm::u16vec2 spriteResolution)
 Creates a SpriteAtlas.

Detailed Description

Holds the sprite atlas and UVs for sprites in it. All spite atlases are padded, so no sprite atlas bleeding will occur.

Note
If SpriteAtlas fails to creat from the specified image, it will be created with the placeholder texture.

Definition at line 12 of file SpriteAtlas.hpp.

Member Function Documentation

◆ Create()

std::shared_ptr< SpriteAtlas > Cori::Graphics::SpriteAtlas::Create ( std::string name,
const std::shared_ptr< Image > & image,
const glm::u16vec2 spriteResolution )
staticnodiscard

Creates a SpriteAtlas.

Parameters
nameName to be assigned to the SpriteAtlas.
imageImage that will be used to create the SpriteAtlas.
spriteResolutionResolution of one sprite in an atlas.
Note
Total image size should be divisible by spriteResolution without a remainder.
Returns
Spared pointer to the created SpriteAtlas.

Definition at line 63 of file SpriteAtlas.cpp.

Here is the call graph for this function:

◆ GetName()

std::string_view Cori::Graphics::SpriteAtlas::GetName ( ) const
nodiscard

Retrieves the name of the SpriteAtlas.

Returns
View to the name of the atlas.

Definition at line 55 of file SpriteAtlas.cpp.

Here is the call graph for this function:

◆ GetSpriteUVsAtIndex()

const UVs & Cori::Graphics::SpriteAtlas::GetSpriteUVsAtIndex ( uint32_t index) const
nodiscard

Request the UVs for the spite at specific index.

Parameters
indexSprite index to request.
Returns
UVs for the requested sprite, or UVs for sprite at index 0 if no sprite with the specified index exist in the SpriteAtlas.

Definition at line 41 of file SpriteAtlas.cpp.

Here is the call graph for this function:

◆ GetSpriteUVsAtPosition()

const UVs & Cori::Graphics::SpriteAtlas::GetSpriteUVsAtPosition ( glm::u16vec2 pos) const
nodiscard

Request the UVs for the spite at specific position.

Parameters
posSprite position to request.
Returns
UVs for the requested sprite, or UVs for sprite at position (0, 0) if no sprite with the specified position in the SpriteAtlas.

Definition at line 46 of file SpriteAtlas.cpp.

Here is the call graph for this function:

◆ GetSuccessStatus()

bool Cori::Graphics::SpriteAtlas::GetSuccessStatus ( ) const
nodiscard

Checks if the SpriteAtlas was created successfully.

Returns
True if successful, false otherwise.

Definition at line 51 of file SpriteAtlas.cpp.

Here is the call graph for this function:

◆ GetTexture()

std::shared_ptr< Texture2D > Cori::Graphics::SpriteAtlas::GetTexture ( ) const
nodiscard

Retrieves the Texture2D stored in the SpriteAtlas.

Returns
Shared pointer to the Texture2D.

Definition at line 59 of file SpriteAtlas.cpp.

Here is the call graph for this function:

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