Organizes a set of textures into a single larger texture (an atlas) by minimizing empty space.
More...
#include <CeresEngine/Texture/TextureAtlasLayout.hpp>
|
| struct | Node |
| | Represent a single node in the texture atlas binary tree. More...
|
| |
|
| | TextureAtlasLayout ()=default |
| |
| | TextureAtlasLayout (const UInt32 width, const UInt32 height) |
| | Constructs a new texture atlas layout with the provided parameters.
|
| |
| | TextureAtlasLayout (const UInt32 width, const UInt32 height, const UInt32 maxWidth, const UInt32 maxHeight, const bool pow2=false) |
| | Constructs a new texture atlas layout with the provided parameters.
|
| |
| bool | addElement (UInt32 width, UInt32 height, UInt32 &x, UInt32 &y) |
| | Attempts to add a new element in the layout.
|
| |
| void | clear () |
| | Removes all entries from the layout.
|
| |
| bool | isEmpty () const |
| | Checks have any elements been added to the layout.
|
| |
| UInt32 | getWidth () const |
| | Returns the width of the atlas texture, in pixels.
|
| |
| UInt32 | getHeight () const |
| | Returns the height of the atlas texture, in pixels.
|
| |
Organizes a set of textures into a single larger texture (an atlas) by minimizing empty space.
◆ TextureAtlasLayout() [1/3]
| CeresEngine::TextureAtlasLayout::TextureAtlasLayout |
( |
| ) |
|
|
default |
◆ TextureAtlasLayout() [2/3]
Constructs a new texture atlas layout with the provided parameters.
- Parameters
-
| width | Initial width of the atlas texture. |
| height | Initial height of the atlas texture. |
◆ TextureAtlasLayout() [3/3]
Constructs a new texture atlas layout with the provided parameters.
- Parameters
-
| width | Initial width of the atlas texture. |
| height | Initial height of the atlas texture. |
| maxWidth | Maximum width the atlas texture is allowed to grow to, when elements don't fit. |
| maxHeight | Maximum height the atlas texture is allowed to grow to, when elements don't fit. |
| pow2 | When true the resulting atlas size will always be a power of two. |
◆ addElement()
Attempts to add a new element in the layout.
Elements should be added to the atlas from largest to smallest, otherwise a non-optimal layout is likely to be generated.
- Parameters
-
| width | Width of the new element, in pixels. |
| height | Height of the new element, in pixels. |
| x | Horizontal position of the new element within the atlas. Only valid if method returns true. |
| y | Vertical position of the new element within the atlas. Only valid if method returns true. |
- Returns
true if the element was added to the atlas, false if the element doesn't fit.
◆ addToNode()
Attempts to add a new element to the specified layout node.
- Parameters
-
| nodeIdx | Index of the node to which to add the element. |
| width | Width of the new element, in pixels. |
| height | Height of the new element, in pixels. |
| x | Horizontal position of the new element within the atlas. Only valid if method returns true. |
| y | Vertical position of the new element within the atlas. Only valid if method returns true. |
| allowGrowth | When true, the width/height of the atlas will be allowed to grow to fit the element. |
- Returns
true if the element was added to the atlas, false if the element doesn't fit.
◆ clear()
| void CeresEngine::TextureAtlasLayout::clear |
( |
| ) |
|
Removes all entries from the layout.
◆ getHeight()
| UInt32 CeresEngine::TextureAtlasLayout::getHeight |
( |
| ) |
const |
|
inline |
Returns the height of the atlas texture, in pixels.
◆ getWidth()
| UInt32 CeresEngine::TextureAtlasLayout::getWidth |
( |
| ) |
const |
|
inline |
Returns the width of the atlas texture, in pixels.
◆ isEmpty()
| bool CeresEngine::TextureAtlasLayout::isEmpty |
( |
| ) |
const |
|
inline |
Checks have any elements been added to the layout.
◆ mHeight
| UInt32 CeresEngine::TextureAtlasLayout::mHeight = 0 |
|
private |
◆ mInitialHeight
| UInt32 CeresEngine::TextureAtlasLayout::mInitialHeight = 0 |
|
private |
◆ mInitialWidth
| UInt32 CeresEngine::TextureAtlasLayout::mInitialWidth = 0 |
|
private |
◆ mNodes
| Vector<Node> CeresEngine::TextureAtlasLayout::mNodes |
|
private |
◆ mPow2
| bool CeresEngine::TextureAtlasLayout::mPow2 = false |
|
private |
◆ mWidth
| UInt32 CeresEngine::TextureAtlasLayout::mWidth = 0 |
|
private |
The documentation for this class was generated from the following file: