galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::resource::TextureAtlas Class Referencefinal

Parses raw texture files and stiches them into a large altas. More...

#include <TextureAtlas.hpp>

+ Collaboration diagram for galaxy::resource::TextureAtlas:

Classes

struct  Info
 Information about textures stored in atlas. More...
 
struct  Sheet
 A sheet of textures in the atlas. More...
 

Public Member Functions

 TextureAtlas ()
 Constructor.
 
virtual ~TextureAtlas ()
 Destructor.
 
void add (const std::string &file)
 Add a single file.
 
void add_from_vfs ()
 Loads all atlas textures in the vfs.
 
void save ()
 Save all created atlas' to disk.
 
void clear ()
 Clear all data.
 
bool contains (const std::string &key)
 Check if atlas contains a texture.
 
meta::optional_ref< Infoquery (const std::string &key)
 Get data about texture in atlas.
 
meta::vector< std::string > keys ()
 Get a list of keys in the cache.
 

Static Public Member Functions

template<meta::is_arithmetic Type>
static float map_x_texel (const Type x, const Type width)
 Takes in a x positon texture coord and maps it to a texel.
 
template<meta::is_arithmetic Type>
static float map_y_texel (const Type y, const Type height)
 Takes in a y positon texture coord and maps it to a texel.
 

Private Member Functions

 TextureAtlas (TextureAtlas &&)=delete
 Move constructor.
 
TextureAtlasoperator= (TextureAtlas &&)=delete
 Move assignment operator.
 
 TextureAtlas (const TextureAtlas &)=delete
 Copy constructor.
 
TextureAtlasoperator= (const TextureAtlas &)=delete
 Copy assignment operator.
 
void init ()
 Initialize atlas.
 

Private Attributes

int m_max_bindings
 Max number of active textures allowed.
 
int m_size
 Maxinum size of an atlas texture.
 
meta::vector< std::unique_ptr< Sheet > > m_sheets
 Texture atlas sheets.
 
robin_hood::unordered_flat_map< std::string, Infom_data
 Index'd list of textures on a sheet.
 
graphics::VertexArray m_vao
 Default vertex array to use when building an atlas.
 
components::Transform m_transform
 Default transform to use when building an atlas.
 

Detailed Description

Parses raw texture files and stiches them into a large altas.

Definition at line 29 of file TextureAtlas.hpp.

Constructor & Destructor Documentation

◆ TextureAtlas() [1/3]

galaxy::resource::TextureAtlas::TextureAtlas ( )

Constructor.

Definition at line 23 of file TextureAtlas.cpp.

+ Here is the call graph for this function:

◆ ~TextureAtlas()

galaxy::resource::TextureAtlas::~TextureAtlas ( )
virtual

Destructor.

Definition at line 30 of file TextureAtlas.cpp.

+ Here is the call graph for this function:

◆ TextureAtlas() [2/3]

galaxy::resource::TextureAtlas::TextureAtlas ( TextureAtlas && )
privatedelete

Move constructor.

◆ TextureAtlas() [3/3]

galaxy::resource::TextureAtlas::TextureAtlas ( const TextureAtlas & )
privatedelete

Copy constructor.

Member Function Documentation

◆ add()

void galaxy::resource::TextureAtlas::add ( const std::string & file)

Add a single file.

Parameters
fileTexture file in the vfs to add to atlas.

Definition at line 35 of file TextureAtlas.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_from_vfs()

void galaxy::resource::TextureAtlas::add_from_vfs ( )

Loads all atlas textures in the vfs.

Definition at line 138 of file TextureAtlas.cpp.

+ Here is the call graph for this function:

◆ save()

void galaxy::resource::TextureAtlas::save ( )

Save all created atlas' to disk.

WARNING: This function will slow down the more atlas' there are to save.

Definition at line 148 of file TextureAtlas.cpp.

◆ clear()

void galaxy::resource::TextureAtlas::clear ( )

Clear all data.

Definition at line 159 of file TextureAtlas.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ contains()

bool galaxy::resource::TextureAtlas::contains ( const std::string & key)
nodiscard

Check if atlas contains a texture.

Parameters
keyIdentifier of texture to look for.
Returns
True if found.

Definition at line 168 of file TextureAtlas.cpp.

+ Here is the caller graph for this function:

◆ query()

meta::optional_ref< TextureAtlas::Info > galaxy::resource::TextureAtlas::query ( const std::string & key)
nodiscard

Get data about texture in atlas.

Parameters
keyIdentifier of texture to query.
Returns
TextureAtlas::Info, as an optional reference.

Definition at line 173 of file TextureAtlas.cpp.

+ Here is the call graph for this function:

◆ map_x_texel()

template<meta::is_arithmetic Type>
float galaxy::resource::TextureAtlas::map_x_texel ( const Type x,
const Type width )
inlinestaticnodiscard

Takes in a x positon texture coord and maps it to a texel.

Template Parameters
TypeType of the variable.
Parameters
xPosition of texture coord.
widthTexture width.
Returns
OpenGL shader compatible texel.

Definition at line 228 of file TextureAtlas.hpp.

+ Here is the caller graph for this function:

◆ map_y_texel()

template<meta::is_arithmetic Type>
float galaxy::resource::TextureAtlas::map_y_texel ( const Type y,
const Type height )
inlinestaticnodiscard

Takes in a y positon texture coord and maps it to a texel.

Template Parameters
TypeType of the variable.
Parameters
yPosition of texture coord.
heightTexture height.
Returns
OpenGL shader compatible texel.

Definition at line 241 of file TextureAtlas.hpp.

+ Here is the caller graph for this function:

◆ keys()

meta::vector< std::string > galaxy::resource::TextureAtlas::keys ( )
nodiscard

Get a list of keys in the cache.

Returns
A vector of strings.

Definition at line 185 of file TextureAtlas.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [1/2]

TextureAtlas & galaxy::resource::TextureAtlas::operator= ( TextureAtlas && )
privatedelete

Move assignment operator.

◆ operator=() [2/2]

TextureAtlas & galaxy::resource::TextureAtlas::operator= ( const TextureAtlas & )
privatedelete

Copy assignment operator.

◆ init()

void galaxy::resource::TextureAtlas::init ( )
private

Initialize atlas.

Definition at line 198 of file TextureAtlas.cpp.

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_max_bindings

int galaxy::resource::TextureAtlas::m_max_bindings
private

Max number of active textures allowed.

Definition at line 199 of file TextureAtlas.hpp.

◆ m_size

int galaxy::resource::TextureAtlas::m_size
private

Maxinum size of an atlas texture.

Definition at line 204 of file TextureAtlas.hpp.

◆ m_sheets

meta::vector<std::unique_ptr<Sheet> > galaxy::resource::TextureAtlas::m_sheets
private

Texture atlas sheets.

Definition at line 209 of file TextureAtlas.hpp.

◆ m_data

robin_hood::unordered_flat_map<std::string, Info> galaxy::resource::TextureAtlas::m_data
private

Index'd list of textures on a sheet.

Definition at line 214 of file TextureAtlas.hpp.

◆ m_vao

graphics::VertexArray galaxy::resource::TextureAtlas::m_vao
private

Default vertex array to use when building an atlas.

Definition at line 219 of file TextureAtlas.hpp.

◆ m_transform

components::Transform galaxy::resource::TextureAtlas::m_transform
private

Default transform to use when building an atlas.

Definition at line 224 of file TextureAtlas.hpp.


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