FPLBase
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
fplbase::TextureAtlas Class Reference

Texture coordinate dictionary. More...

#include <texture_atlas.h>

Inheritance diagram for fplbase::TextureAtlas:
fplbase::Asset

Detailed Description

Texture coordinate dictionary.

A TextureAtlas supports sprite sheets by containing one texture and a list of subtexture bounding boxes, which can also be indexed by name using the index_map. Subtexture bounding boxes are returned in normalized texture coordinates, and take the form (u, v, width, height).

Warning
This is will very likely be refactored.

Public Member Functions

void Delete ()
 Delete the texture associated with this atlas.
 
const vec4 * GetBounds (const std::string &name)
 Get the bounds of a subtexture associated with name. More...
 
const Textureatlas_texture () const
 Get the texture associated with this atlas. More...
 
Textureatlas_texture ()
 Get the texture associated with this atlas. More...
 
void set_atlas_texture (Texture *atlas_texture)
 Set the texture associated with this atlas.
 
const std::vector< vec4 > & subtexture_bounds () const
 Get a vector of the bounds of each subtexture in this atlas. More...
 
std::vector< vec4 > & subtexture_bounds ()
 Get a vector of the bounds of each subtexture in this atlas. More...
 
const std::map< std::string,
size_t > & 
index_map () const
 Get a map of subtexture names to subtexture offsets. More...
 
std::map< std::string, size_t > & index_map ()
 Get a map of subtexture names to subtexture offsets. More...
 
- Public Member Functions inherited from fplbase::Asset
void IncreaseRefCount ()
 indicate there is an additional owner of this asset. By default, when you call any of the UnLoad*() functions in the AssetManager, that will directly delete the asset since they all start out with a single reference count. Call this function to indicate multiple owners will call Unload*() independently, and only have the asset deleted by the last one.
 

Static Public Member Functions

static TextureAtlasLoadTextureAtlas (const char *filename, TextureFormat format, TextureFlags flags, const TextureLoaderFn &tlf)
 Load a texture atlas file. Used by the more convenient AssetManager interface, but can be used without it.
 

Member Function Documentation

const Texture* fplbase::TextureAtlas::atlas_texture ( ) const
inline

Get the texture associated with this atlas.

Returns
Pointer to the texture associated with this atlas.
Texture* fplbase::TextureAtlas::atlas_texture ( )
inline

Get the texture associated with this atlas.

Returns
Pointer to the texture associated with this atlas.
const vec4* fplbase::TextureAtlas::GetBounds ( const std::string &  name)
inline

Get the bounds of a subtexture associated with name.

Parameters
nameName of the subtexture to lookup.
Returns
Bounds of the subtexture or nullptr if the specified name isn't found.
const std::map<std::string, size_t>& fplbase::TextureAtlas::index_map ( ) const
inline

Get a map of subtexture names to subtexture offsets.

Each entry in the map can be used to lookup the subtexture bounds in the vector returned by subtexture_bounds().

Returns
A map of subtexture names to indices in vector returned by subtexture_bounds().
std::map<std::string, size_t>& fplbase::TextureAtlas::index_map ( )
inline

Get a map of subtexture names to subtexture offsets.

Each entry in the map can be used to lookup the subtexture bounds in the vector returned by subtexture_bounds().

Returns
A map of subtexture names to indices in vector returned by subtexture_bounds().
const std::vector<vec4>& fplbase::TextureAtlas::subtexture_bounds ( ) const
inline

Get a vector of the bounds of each subtexture in this atlas.

Each element of the vector consists of (offsetx, offsety, sizex, sizey) where offsetx / offsety are coordinates relative to the underlying atlased texture and sizex / sizey are the dimensions of the subtexture.

Returns
Vector of subtexture bounds.
std::vector<vec4>& fplbase::TextureAtlas::subtexture_bounds ( )
inline

Get a vector of the bounds of each subtexture in this atlas.

Each element of the vector consists of (offsetx, offsety, sizex, sizey) where offsetx / offsety are coordinates relative to the underlying atlased texture and sizex / sizey are the dimensions of the subtexture.

Returns
Vector of subtexture bounds.

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