class EE::Graphics::TextureAtlas¶
Overview¶
The texture atlas class represents a large image containing a collection of sub-images, or “atlas” which contains many smaller sub-images. The texture atlas in eepp can represent more than one texture or image, but the common use should be a image with sub-images. More information about Texture Atlases: http://en.wikipedia.org/wiki/Texture_atlas. More…
#include <textureatlas.hpp> class TextureAtlas { public: // construction TextureAtlas(const std::string& name = ""); ~TextureAtlas(); // methods static TextureAtlasPtr New(const std::string& name = ""); TextureRegionPtr add(TextureRegionPtr textureRegion); TextureRegionPtr add(ResourceId textureId, const std::string& Name = ""); TextureRegionPtr add(ResourceId textureId, const Rect& SrcRect, const std::string& Name = ""); TextureRegionPtr add(ResourceId textureId, const Rect& SrcRect, const Sizef& DestSize, const std::string& Name = ""); TextureRegionPtr add(ResourceId textureId, const Rect& SrcRect, const Sizef& DestSize, const Vector2i& Offset, const std::string& Name = ""); TextureRegionPtr add(TexturePtr tex, const std::string& Name = ""); TextureRegionPtr add(TexturePtr tex, const Rect& SrcRect, const std::string& Name = ""); TextureRegionPtr add(TexturePtr tex, const Rect& SrcRect, const Sizef& DestSize, const std::string& Name = ""); TextureRegionPtr add(TexturePtr tex, const Rect& SrcRect, const Sizef& DestSize, const Vector2i& Offset, const std::string& Name = ""); TextureRegionPtr getByName(const std::string& name) const; TextureRegionPtr getById(const String::HashType& id) const; bool remove(const TextureRegionPtr& textureRegion); bool removeByName(const std::string& name); bool removeById(const String::HashType& id); bool exists(const std::string& name) const; bool existsId(const String::HashType& id) const; void clear(); void printNames() const; const UnorderedMap<String::HashType, TextureRegionPtr>& getResources() const; const std::string& getName() const; void setName(const std::string& name); const std::string& getPath() const; void setPath(const std::string& path); const String::HashType& getId() const; Uint32 getCount() const; const TexturePtr& getTexture(const Uint32& texnum = 0) const; Uint32 getTexturesCount() const; };
Detailed Documentation¶
The texture atlas class represents a large image containing a collection of sub-images, or “atlas” which contains many smaller sub-images. The texture atlas in eepp can represent more than one texture or image, but the common use should be a image with sub-images. More information about Texture Atlases: http://en.wikipedia.org/wiki/Texture_atlas.
Construction¶
TextureAtlas(const std::string& name = "")
Creates a new texture atlas with the given name.
Methods¶
TextureRegionPtr add(TextureRegionPtr textureRegion)
Adds a TextureRegion to the Texture Atlas
TextureRegionPtr add(ResourceId textureId, const std::string& Name = "")
Creates and add to the texture atlas a TextureRegion from a Texture. It will use the full Texture as a TextureRegion.
Parameters:
textureId |
The texture identity |
Name |
The texture name ( if any ) |
TextureRegionPtr add(ResourceId textureId, const Rect& SrcRect, const std::string& Name = "")
Creates and add to the texture atlas a TextureRegion of the indicated part of the texture.
Parameters:
textureId |
The texture identity |
SrcRect |
The texture part that will be used as the TextureRegion. |
Name |
The texture name ( if any ) |
TextureRegionPtr add(ResourceId textureId, const Rect& SrcRect, const Sizef& DestSize, const std::string& Name = "")
Creates and add to the texture atlas a TextureRegion of the indicated part of the texture.
Parameters:
textureId |
The texture identity |
SrcRect |
The texture part that will be used as the TextureRegion. |
DestSize |
The destination size that the TextureRegion will have when rendered. |
Name |
The texture name ( if any ) |
TextureRegionPtr add(ResourceId textureId, const Rect& SrcRect, const Sizef& DestSize, const Vector2i& Offset, const std::string& Name = "")
Creates and add to the texture atlas a TextureRegion of the indicated part of the texture.
Parameters:
textureId |
The texture identity |
SrcRect |
The texture part that will be used as the TextureRegion. |
DestSize |
The destination size that the TextureRegion will have when rendered. |
Offset |
The offset that will be added to the position passed when any Draw call is used. |
Name |
The texture name ( if any ) |
TextureRegionPtr add(TexturePtr tex, const std::string& Name = "")
Creates and add to the texture atlas a TextureRegion from a Texture. It will use the full Texture as a TextureRegion.
Parameters:
tex |
The texture |
Name |
The texture name ( if any ) |
TextureRegionPtr add(TexturePtr tex, const Rect& SrcRect, const std::string& Name = "")
Creates and add to the texture atlas a TextureRegion of the indicated part of the texture.
Parameters:
tex |
The texture |
SrcRect |
The texture part that will be used as the TextureRegion. |
Name |
The texture name ( if any ) |
TextureRegionPtr add(TexturePtr tex, const Rect& SrcRect, const Sizef& DestSize, const std::string& Name = "")
Creates and add to the texture atlas a TextureRegion of the indicated part of the texture.
Parameters:
tex |
The texture |
SrcRect |
The texture part that will be used as the TextureRegion. |
DestSize |
The destination size that the TextureRegion will have when rendered. |
Name |
The texture name ( if any ) |
TextureRegionPtr add(TexturePtr tex, const Rect& SrcRect, const Sizef& DestSize, const Vector2i& Offset, const std::string& Name = "")
Creates and add to the texture atlas a TextureRegion of the indicated part of the texture.
Parameters:
tex |
The texture |
SrcRect |
The texture part that will be used as the TextureRegion. |
DestSize |
The destination size that the TextureRegion will have when rendered. |
Offset |
The offset that will be added to the position passed when any Draw call is used. |
Name |
The texture name ( if any ) |
const std::string& getName() const
Returns:
The texture atlas name.
void setName(const std::string& name)
Sets the texture atlas name.
const std::string& getPath() const
Returns:
The texture atlas path.
void setPath(const std::string& path)
Sets the texture atlas path.
const String::HashType& getId() const
Returns:
The texture atlas Id. The Id is the String::hash of the texture atlas name.
Uint32 getCount() const
Returns:
The number of TextureRegions inside the texture atlas.
const TexturePtr& getTexture(const Uint32& texnum = 0) const
Note
Some texture atlases could not have any texture, since you can use it as a container of TextureRegions from any texture.
The texture atlases loaded from a file always will be linked to a texture.
The Global Texture Atlas for example doesn’t have any texture linked to it.
Parameters:
texnum |
The texture index. A texture atlas can use more than one texture, so it can be 0 to getTexturesCount(). Usually a texture atlas corresponds to only one texture, so the texture index is 0. |
Returns:
The texture that corresponds to the texture atlas.
Uint32 getTexturesCount() const
Returns:
The number of textures linked to the texture atlas.