You.i Engine
CYITextureAtlas Class Reference

Detailed Description

Class for a texture atlas.

#include <graphics/YiTextureAtlas.h>

Inheritance diagram for CYITextureAtlas:

Public Member Functions

 CYITextureAtlas ()
 
virtual ~CYITextureAtlas ()
 
bool CreateNewAtlas (uint32_t unWidth, uint32_t unHeight, size_t pages)
 
YI_REGION GetRegion (int32_t width, int32_t height)
 
virtual void SetRegion (ssize_t ID, void *pReference, YI_REGION Region, const uint8_t *data, const int32_t stride)
 
virtual YI_TEXTURE_DETAILSGetTexture (ssize_t ID, void *pReference)
 
void UpdateAtlas ()
 
const std::shared_ptr< CYIBitmapGetBitmap () const
 
const std::vector< glm::ivec4 > * GetNodes (size_t page) const
 
virtual std::shared_ptr< CYIAssetTextureGetGLTexture () const
 
const std::shared_ptr< CYIAssetTextureGetTextureAsset ()
 
YI_LOADED_TEXTURESGetLoadedTextures ()
 
void SetTextureFilter (CYIAssetTexture::Filtering minificationFilter, CYIAssetTexture::Filtering magnificationFilter)
 
void SetTextureWrap (CYIAssetTexture::WrapMode wrapS, CYIAssetTexture::WrapMode wrapT)
 
void SetName (const CYIString &name)
 
const CYIStringGetName () const
 
float GetAtlasPercentageUsed () const
 
bool RenderAtlasToPng (const CYIString &filePath) const
 
void Reset ()
 

Protected Member Functions

int32_t Fit (size_t page, size_t unIndex, int32_t width, int32_t height)
 
void Merge (size_t page)
 

Protected Attributes

CYIString m_name
 
std::shared_ptr< CYIBitmapm_Image
 
std::vector< glm::ivec4 > m_Nodes [4]
 
std::shared_ptr< CYIAssetTexturem_pTextureAsset
 
YI_LOADED_TEXTURES m_Textures
 
int32_t m_width
 
int32_t m_height
 
size_t m_pages
 
CYIAssetTexture::TextureConfig m_textureConfiguration
 
size_t m_unPixelsUsed
 
size_t m_unLastUpdatedSize
 

Constructor & Destructor Documentation

◆ CYITextureAtlas()

CYITextureAtlas::CYITextureAtlas ( )

◆ ~CYITextureAtlas()

virtual CYITextureAtlas::~CYITextureAtlas ( )
virtual

Member Function Documentation

◆ CreateNewAtlas()

bool CYITextureAtlas::CreateNewAtlas ( uint32_t  unWidth,
uint32_t  unHeight,
size_t  pages 
)

◆ Fit()

int32_t CYITextureAtlas::Fit ( size_t  page,
size_t  unIndex,
int32_t  width,
int32_t  height 
)
protected

◆ GetAtlasPercentageUsed()

float CYITextureAtlas::GetAtlasPercentageUsed ( ) const

Returns the atlas usage as a percentage. The calculation is total pixels / used pixels. Note that this is the exact pixel usage of the atlas. If the packing method used isn't 100% efficient then the atlas will never reach 100% usage. This function returns a value in the range from 0.0 to 1.0.

◆ GetBitmap()

const std::shared_ptr<CYIBitmap> CYITextureAtlas::GetBitmap ( ) const

◆ GetGLTexture()

virtual std::shared_ptr<CYIAssetTexture> CYITextureAtlas::GetGLTexture ( ) const
virtual

◆ GetLoadedTextures()

YI_LOADED_TEXTURES* CYITextureAtlas::GetLoadedTextures ( )

◆ GetName()

const CYIString& CYITextureAtlas::GetName ( ) const

◆ GetNodes()

const std::vector<glm::ivec4>* CYITextureAtlas::GetNodes ( size_t  page) const

◆ GetRegion()

YI_REGION CYITextureAtlas::GetRegion ( int32_t  width,
int32_t  height 
)

◆ GetTexture()

virtual YI_TEXTURE_DETAILS* CYITextureAtlas::GetTexture ( ssize_t  ID,
void *  pReference 
)
virtual

Reimplemented in CYIAbstractTextAtlas.

◆ GetTextureAsset()

const std::shared_ptr<CYIAssetTexture> CYITextureAtlas::GetTextureAsset ( )
inline

◆ Merge()

void CYITextureAtlas::Merge ( size_t  page)
protected

◆ RenderAtlasToPng()

bool CYITextureAtlas::RenderAtlasToPng ( const CYIString filePath) const

Renders the current contents of the texture atlas to the given file path. Returns true if the image was successfully written.

◆ Reset()

void CYITextureAtlas::Reset ( )

Resets all regions in the atlas and clears the contents of the underlying texture.

◆ SetName()

void CYITextureAtlas::SetName ( const CYIString name)

◆ SetRegion()

virtual void CYITextureAtlas::SetRegion ( ssize_t  ID,
void *  pReference,
YI_REGION  Region,
const uint8_t *  data,
const int32_t  stride 
)
virtual

◆ SetTextureFilter()

void CYITextureAtlas::SetTextureFilter ( CYIAssetTexture::Filtering  minificationFilter,
CYIAssetTexture::Filtering  magnificationFilter 
)

◆ SetTextureWrap()

void CYITextureAtlas::SetTextureWrap ( CYIAssetTexture::WrapMode  wrapS,
CYIAssetTexture::WrapMode  wrapT 
)

◆ UpdateAtlas()

void CYITextureAtlas::UpdateAtlas ( )

Member Data Documentation

◆ m_height

int32_t CYITextureAtlas::m_height
protected

◆ m_Image

std::shared_ptr<CYIBitmap> CYITextureAtlas::m_Image
protected

◆ m_name

CYIString CYITextureAtlas::m_name
protected

◆ m_Nodes

std::vector<glm::ivec4> CYITextureAtlas::m_Nodes[4]
protected

◆ m_pages

size_t CYITextureAtlas::m_pages
protected

◆ m_pTextureAsset

std::shared_ptr<CYIAssetTexture> CYITextureAtlas::m_pTextureAsset
protected

◆ m_textureConfiguration

CYIAssetTexture::TextureConfig CYITextureAtlas::m_textureConfiguration
protected

◆ m_Textures

YI_LOADED_TEXTURES CYITextureAtlas::m_Textures
protected

◆ m_unLastUpdatedSize

size_t CYITextureAtlas::m_unLastUpdatedSize
protected

◆ m_unPixelsUsed

size_t CYITextureAtlas::m_unPixelsUsed
protected

◆ m_width

int32_t CYITextureAtlas::m_width
protected

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