Texture grouping class. More...

#include <texture_group.h>

Public Types

enum  TextureAllocationPolicy { create_new_texture , search_previous_textures }
 Texture allocation policy. More...
 

Public Member Functions

 TextureGroup ()
 Constructs a null instance.
 
 TextureGroup (const Size &texture_sizes)
 Constructs a texture group.
 
 ~TextureGroup ()
 
Subtexture add (GraphicContext &context, const Size &size)
 Allocate space for another sub texture.
 
int get_subtexture_count () const
 Returns the amount of sub-textures allocated in group.
 
int get_subtexture_count (unsigned int texture_index) const
 Returns the amount of sub-textures for a specific texture index.
 
TextureAllocationPolicy get_texture_allocation_policy () const
 Returns the texture allocation policy.
 
int get_texture_count () const
 Returns the amount of textures used by group.
 
Size get_texture_sizes () const
 Returns the size of the textures used by this texture group.
 
std::vector< Texture2Dget_textures () const
 Returns the textures.
 
void insert_texture (Texture2D &texture, const Rect &texture_rect)
 Insert an existing texture into the texture group.
 
bool is_null () const
 Returns true if this object is invalid.
 
 operator bool () const
 
void remove (Subtexture &subtexture)
 Deallocate space, from a previously allocated texture.
 
void set_texture_allocation_policy (TextureAllocationPolicy policy)
 Set the texture allocation policy.
 
void throw_if_null () const
 Throw an exception if this object is invalid.
 

Detailed Description

Texture grouping class.

Member Enumeration Documentation

◆ TextureAllocationPolicy

Texture allocation policy.

Enumerator
create_new_texture 
search_previous_textures 

Constructor & Destructor Documentation

◆ TextureGroup() [1/2]

clan::TextureGroup::TextureGroup ( )

Constructs a null instance.

◆ TextureGroup() [2/2]

clan::TextureGroup::TextureGroup ( const Size & texture_sizes)

Constructs a texture group.

◆ ~TextureGroup()

clan::TextureGroup::~TextureGroup ( )

Member Function Documentation

◆ add()

Subtexture clan::TextureGroup::add ( GraphicContext & context,
const Size & size )

Allocate space for another sub texture.

◆ get_subtexture_count() [1/2]

int clan::TextureGroup::get_subtexture_count ( ) const

Returns the amount of sub-textures allocated in group.

◆ get_subtexture_count() [2/2]

int clan::TextureGroup::get_subtexture_count ( unsigned int texture_index) const

Returns the amount of sub-textures for a specific texture index.

◆ get_texture_allocation_policy()

TextureAllocationPolicy clan::TextureGroup::get_texture_allocation_policy ( ) const

Returns the texture allocation policy.

◆ get_texture_count()

int clan::TextureGroup::get_texture_count ( ) const

Returns the amount of textures used by group.

◆ get_texture_sizes()

Size clan::TextureGroup::get_texture_sizes ( ) const

Returns the size of the textures used by this texture group.

◆ get_textures()

std::vector< Texture2D > clan::TextureGroup::get_textures ( ) const

Returns the textures.

◆ insert_texture()

void clan::TextureGroup::insert_texture ( Texture2D & texture,
const Rect & texture_rect )

Insert an existing texture into the texture group.

Parameters
texture= Texture to insert
texture_rect= Free space within the texture that the texture group can use

◆ is_null()

bool clan::TextureGroup::is_null ( ) const
inline

Returns true if this object is invalid.

◆ operator bool()

clan::TextureGroup::operator bool ( ) const
inlineexplicit

◆ remove()

void clan::TextureGroup::remove ( Subtexture & subtexture)

Deallocate space, from a previously allocated texture.

Warning - It is advised to set TextureAllocationPolicy to search_previous_textures if using this function. Also be aware of texture fragmentation. Empty textures are not removed.

◆ set_texture_allocation_policy()

void clan::TextureGroup::set_texture_allocation_policy ( TextureAllocationPolicy policy)

Set the texture allocation policy.

◆ throw_if_null()

void clan::TextureGroup::throw_if_null ( ) const

Throw an exception if this object is invalid.


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