OpenGLContext.atlas
Texture atlas implementation
Classes
Strip within the atlas which takes particular set of images
Collection of textures packed into a single texture
Texture atlases allow the rendering engine to reduce the
number of state-changes which occur during the rendering
process. They pack a large number of small textures into
a single large texture, producing offset/scale matrices to
use for modifying texture coordinates to map from the
original to the packed coordinates.
add(
self
,
image
)
Insert a PIL image of values as a sub-texture
Has to find a place within the atlas to insert the
sub-texture and then return the offset/scale factors...
class AtlasError(
Exception
):
Raised when we can't/shouldn't append to this atlas
class AtlasManager(
object
):
Object representing a sub-texture within a texture atlas
A Map object is a dependent version of an OpenGLContext.texture.Texture
object, i.e. it tries to offer the same API, but with support for
Atlas-based maps instead of stand-alone ones.
texture
Retrieve our texture
matrix(
self
)
Calculate a 4x4 transform matrix for texcoords
To manipulate texture coordinates with this matrix
they need to be in homogenous coordinates, i.e. a
"regular" 2d coordinate of (x,y) becomes (x,y,0.0,1.0)
so that it can pick up the translations.
dot( coord, matrix ) produces the transformed
coordinate for processing.
returns 4x4 translation matrix