4.1.3.16. TextureAtlas

class PyOpenGLng.HighLevelApi.TextureAtlas.TextureAtlas(width=1024, height=1024, depth=1)[source]

Group multiple small data regions into a larger texture.

The algorithm is based on the article by Jukka Jylänki : “A Thousand Ways to Pack the Bin - A Practical Approach to Two-Dimensional Rectangle Bin Packing”, February 27, 2010. More precisely, this is an implementation of the Skyline Bottom-Left algorithm based on C++ sources provided by Jukka Jylänki at: http://clb.demon.fi/files/RectangleBinPack/

Example usage:

atlas = TextureAtlas(512,512,3)
region = atlas.get_region(20,20)
...
atlas.set_region(region, data)

Initialize a new atlas of given size.

Parameters

width : int
Width of the underlying texture
height : int
Height of the underlying texture
depth : 1 or 3
Depth of the underlying texture
_fit(index, width, height)[source]

Test if region (width,height) fit into self._nodes[index]

Parameters

index : int
Index of the internal node to be tested
width : int
Width or the region to be tested
height : int
Height or the region to be tested
_logger = <logging.Logger object at 0x5b0b450>
_merge()[source]

Merge nodes

data[source]
depth[source]
get_region(width, height)[source]

Get a free region of given size and allocate it

Parameters

width : int
Width of region to allocate
height : int
Height of region to allocate
Return
A newly allocated region as (x,y,width,height) or (-1,-1,0,0)
height[source]
save(filename)[source]
set_region(region, data)[source]

Set a given region width provided data.

Parameters

region : (int,int,int,int)
an allocated region (x,y,width,height)
data : numpy array
data to be copied into given region
width[source]
PyOpenGLng.HighLevelApi.TextureAtlas.ceil2(x)[source]

Compute the smallest power of 2 >= x

Previous topic

4.1.3.15. TextVertexArray

Next topic

4.1.3.17. TextureFont

This Page