Detailed Description

Represents a texture atlas which is dynamically added to and modified. Must be used with an AtlasStack. It internally tracks which textures it has to prevent frequent rebuilds. By using a texture atlas like this, many drawcalls can be compressed to one. It also supports dynamic textures. These write directly to the atlas pixels.

Public Member Functions

 TextureAtlas ()
 Generates a new texture atlas of size 1024px x 1024px. More...
 
 TextureAtlas (int dimension)
 
 TextureAtlas (int dimension, FilterMode filter, TextureFormat format)
 Generates a new atlas with the given x/y dimension (all atlases are square). More...
 
void RemoveFromStack ()
 Removes this atlas from the stack. More...
 
void Flush ()
 Flushes changes to the pixel set to the texture. More...
 
bool Optimize ()
 Optimizes the atlas by removing all 'holes' (removed images) from the atlas. It reconstructs the whole atlas (only when there are actually holes), so this method should be considered expensive. This is only ever called when we fail to add something to the atlas; Theres no performace issues of a non-optimized atlas. Instead it just simply has very fragmented space available. More...
 
void Destroy ()
 Destroys this atlas when it's no longer needed. More...
 

Public Attributes

AtlasStack Stack
 The parent stack. More...
 
TextureAtlas Next
 Atlases are stored in a stack. The next one. More...
 
TextureAtlas Previous
 Atlases are stored in a stack. The previous one. More...
 
int Dimension
 The length of the sides of the atlas, in pixels. More...
 
float DimensionF
 The length of the sides of the atlas, in pixels, as a float. More...
 
float InvertedSize
 1/the dimension. More...
 
Color32[] Pixels
 The block of all pixels of this atlas. More...
 
bool PixelChange
 True if any pixels were changed. More...
 
bool CanOptimize
 True if an image was removed from the atlas and it now has a 'hole'. More...
 
Texture2D Texture
 The pixels of the atlas as a displayable texture. More...
 
bool OptimizeRequested
 True if something failed to be added that would otherwise have fit. More...
 
AtlasLocation LastEmpty
 Images which are removed are stored in a linked list. This is the tail of the list. More...
 
AtlasLocation FirstEmpty
 Images which are removed are stored in a linked list. This is the head of the list. More...
 

Package Functions

void Reset ()
 Clears all content from this atlas More...
 
bool OptimiseAdd (AtlasLocation location)
 Attempts to add the "remote" atlas location to this atlas. The original location object is retained. More...
 
AtlasLocation Add (AtlasEntity texture, int entityID, int width, int height)
 Adds the given texture to the atlas if it's not already on it, taking up a set amount of space on the atlas. More...
 

Properties

FilterMode FilterMode [get, set]
 The filter mode of this atlas. More...
 

Constructor & Destructor Documentation

Blaze.TextureAtlas.TextureAtlas ( )
inline

Generates a new texture atlas of size 1024px x 1024px.

Blaze.TextureAtlas.TextureAtlas ( int  dimension)
inline
Blaze.TextureAtlas.TextureAtlas ( int  dimension,
FilterMode  filter,
TextureFormat  format 
)
inline

Generates a new atlas with the given x/y dimension (all atlases are square).

Parameters
dimensionThe length in pixels of the side of the atlas.

Member Function Documentation

AtlasLocation Blaze.TextureAtlas.Add ( AtlasEntity  texture,
int  entityID,
int  width,
int  height 
)
inlinepackage

Adds the given texture to the atlas if it's not already on it, taking up a set amount of space on the atlas.

Parameters
textureThe texture to add.
widthThe x amount of space to take up on the atlas.
heightThe y amount of space to take up on the atlas.
Returns
The location of the texture on the atlas.
void Blaze.TextureAtlas.Destroy ( )
inline

Destroys this atlas when it's no longer needed.

void Blaze.TextureAtlas.Flush ( )
inline

Flushes changes to the pixel set to the texture.

bool Blaze.TextureAtlas.OptimiseAdd ( AtlasLocation  location)
inlinepackage

Attempts to add the "remote" atlas location to this atlas. The original location object is retained.

Returns
True if this atlas accepted the location.
bool Blaze.TextureAtlas.Optimize ( )
inline

Optimizes the atlas by removing all 'holes' (removed images) from the atlas. It reconstructs the whole atlas (only when there are actually holes), so this method should be considered expensive. This is only ever called when we fail to add something to the atlas; Theres no performace issues of a non-optimized atlas. Instead it just simply has very fragmented space available.

void Blaze.TextureAtlas.RemoveFromStack ( )
inline

Removes this atlas from the stack.

void Blaze.TextureAtlas.Reset ( )
inlinepackage

Clears all content from this atlas

Member Data Documentation

bool Blaze.TextureAtlas.CanOptimize

True if an image was removed from the atlas and it now has a 'hole'.

int Blaze.TextureAtlas.Dimension

The length of the sides of the atlas, in pixels.

float Blaze.TextureAtlas.DimensionF

The length of the sides of the atlas, in pixels, as a float.

AtlasLocation Blaze.TextureAtlas.FirstEmpty

Images which are removed are stored in a linked list. This is the head of the list.

float Blaze.TextureAtlas.InvertedSize

1/the dimension.

AtlasLocation Blaze.TextureAtlas.LastEmpty

Images which are removed are stored in a linked list. This is the tail of the list.

TextureAtlas Blaze.TextureAtlas.Next

Atlases are stored in a stack. The next one.

bool Blaze.TextureAtlas.OptimizeRequested

True if something failed to be added that would otherwise have fit.

bool Blaze.TextureAtlas.PixelChange

True if any pixels were changed.

Color32 [] Blaze.TextureAtlas.Pixels

The block of all pixels of this atlas.

TextureAtlas Blaze.TextureAtlas.Previous

Atlases are stored in a stack. The previous one.

AtlasStack Blaze.TextureAtlas.Stack

The parent stack.

Texture2D Blaze.TextureAtlas.Texture

The pixels of the atlas as a displayable texture.

Property Documentation

FilterMode Blaze.TextureAtlas.FilterMode
getset

The filter mode of this atlas.