![]() |
Jopnal Engine
alpha 0.4
Simple Component Based 2D/3D Game Engine
|
#include <TextureAtlas.hpp>
Public Types | |
| enum | LoadMode { LoadMode::Separate, LoadMode::Sheet, LoadMode::TextureOnly } |
| Load mode. More... | |
Public Member Functions | |
| TextureAtlas (const std::string &name) | |
| Constructor. More... | |
| ~TextureAtlas () override | |
| Destructor. More... | |
| bool | load (const glm::uvec2 &atlasSize) |
| Load an empty atlas. More... | |
| template<typename... Args> | |
| bool | load (const glm::uvec2 &atlasSize, const Args &...args) |
| Load this atlas. More... | |
| bool | load (const std::string &path, const LoadMode mode) |
| Load from JSON file. More... | |
| void | destroy () |
| Destroy this atlas. More... | |
| unsigned int | addTexture (const Image &image) |
| Add texture from image to the atlas. More... | |
| unsigned int | addTexture (const Texture2D &texture) |
| Add texture to the atlas. More... | |
| unsigned int | addTexture (const std::string &texturePath) |
| Add texture from file to atlas. More... | |
| unsigned int | defineTexture (const glm::vec2 &start, const glm::vec2 &end) |
| Define a texture. More... | |
| std::pair< glm::vec2, glm::vec2 > | getCoordinates (const unsigned int index) const |
| Get texture location inside atlas. More... | |
| unsigned int | getTextureAmount () const |
| Get amount of textures inside atlas. More... | |
| const Texture2D & | getTexture () const |
| Get the texture of atlas. More... | |
Public Member Functions inherited from jop::Resource | |
| Resource (const std::string &name) | |
| Constructor. More... | |
| virtual | ~Resource ()=0 |
| Virtual destructor. More... | |
| const std::string & | getName () const |
| Get the name of this resource. More... | |
| void | setPersistence (const unsigned short level) |
| Set the persistence level. More... | |
| unsigned short | getPersistence () const |
| Get the persistence level. More... | |
Public Member Functions inherited from jop::SafeReferenceable< Resource > | |
| WeakReference< Resource > | getReference () const |
| Get a weak reference to the bound object. More... | |
Public Member Functions inherited from jop::SerializeInfo | |
| SerializeInfo () | |
| void | setSerializePackage (const uint16 package) |
| uint16 | getSerializePackage () const |
| void | setShouldSerialize (const bool set) |
| bool | shouldSerialize () const |
| void | setLightSerializeable (const bool set) |
| bool | isLightSerializeable () const |
Additional Inherited Members | |
Protected Member Functions inherited from jop::Resource | |
| Resource (const Resource &other, const std::string &newName) | |
| Copy constructor. More... | |
Protected Member Functions inherited from jop::SafeReferenceable< Resource > | |
| SafeReferenceable (Resource *ref) | |
| Constructor. More... | |
| SafeReferenceable (SafeReferenceable< Resource > &&other) | |
| Move constructor. More... | |
| SafeReferenceable & | operator= (SafeReferenceable< Resource > &&other) |
| Move assignment operator. More... | |
| ~SafeReferenceable () | |
| Protected destructor. More... | |
Definition at line 42 of file TextureAtlas.hpp.
|
strong |
Load mode.
| Enumerator | |
|---|---|
| Separate |
Load from separate textures. |
| Sheet |
Use if you have a complete sheet (inside a single texture) |
| TextureOnly |
Only load the texture. |
Definition at line 47 of file TextureAtlas.hpp.
| jop::TextureAtlas::TextureAtlas | ( | const std::string & | name | ) |
Constructor.
| name | Name for the resource |
|
override |
Destructor.
| unsigned int jop::TextureAtlas::addTexture | ( | const Image & | image | ) |
| unsigned int jop::TextureAtlas::addTexture | ( | const Texture2D & | texture | ) |
| unsigned int jop::TextureAtlas::addTexture | ( | const std::string & | texturePath | ) |
Add texture from file to atlas.
| texturePath | Path to the texture in file |
| unsigned int jop::TextureAtlas::defineTexture | ( | const glm::vec2 & | start, |
| const glm::vec2 & | end | ||
| ) |
Define a texture.
Adds a texture to memory with given dimension. This call must not be mixed with addTexture().
| start | The start coordinates |
| end | The end coordinates |
| void jop::TextureAtlas::destroy | ( | ) |
Destroy this atlas.
Called implicitly by all load methods.
| std::pair<glm::vec2, glm::vec2> jop::TextureAtlas::getCoordinates | ( | const unsigned int | index | ) | const |
Get texture location inside atlas.
| index | Index of the texture |
| const Texture2D& jop::TextureAtlas::getTexture | ( | ) | const |
Get the texture of atlas.
If no textures have been added to atlas default texture will be returned.
| unsigned int jop::TextureAtlas::getTextureAmount | ( | ) | const |
Get amount of textures inside atlas.
| bool jop::TextureAtlas::load | ( | const glm::uvec2 & | atlasSize | ) |
Load an empty atlas.
| atlasSize | Size of the atlas to be created |
| bool jop::TextureAtlas::load | ( | const glm::uvec2 & | atlasSize, |
| const Args &... | args | ||
| ) |
Load this atlas.
Loads this atlas of given size and with variable amount of given Images, Texture2D's or file paths using addTexture() for each argument.
| atlasSize | Size of the atlas to be created |
| args | Variable amount of Texture2D's, Images or file paths |
| bool jop::TextureAtlas::load | ( | const std::string & | path, |
| const LoadMode | mode | ||
| ) |
Load from JSON file.
| path | Path to the JSON file |
| mode | Load mode |
Information about the JSON formats.
1.8.11