Next: , Up: Graphics   [Contents][Index]


2.3.1 Textures

Procedure: load-image file [#:min-filter nearest] [#:mag-filter nearest] [#:wrap-s repeat] [#:wrap-t repeat]

Load the image data from file and return a new texture object.

min-filter and mag-filter describe the method that should be used for minification and magnification when rendering, respectively. Possible values are nearest and linear.

wrap-s and wrap-t describe how to interpret texture coordinates that are greater than 1.0. Possible values are repeat, clamp, clamp-to-border, and clamp-to-edge.

Procedure: texture? obj

Return #t if obj is a texture.

Procedure: texture-region? obj

Return #t if obj is a texture region.

Procedure: texture-parent texture

If texture is a texture region, return the full texture that it is based upon. Otherwise, return #f.

Procedure: texture-min-filter texture

Return the minification filter for texture, either nearest or linear.

Procedure: texture-mag-filter texture

Return the magnification filter for texture, either nearest or linear.

Procedure: texture-wrap-s texture

Return the method used for wrapping texture coordinates along the X axis for texture.

Possible wrapping methods:

Procedure: texture-wrap-t texture

Return the method used for wrapping texture coordinates along the Y axis for texture.

Procedure: texture-width texture

Return the width of texture in pixels.

Procedure: texture-height texture

Return the height of texture in pixels.

It is common practice to combine multiple bitmap images into a single texture, known as a “tile atlas” or “tile set”, because it is more efficient to render many regions of a large texture than it is to render a bunch of small textures. Chickadee provides a tile atlas data type for collecting texture regions into a single vector.

Procedure: split-texture texture tile-width tile-height [#:margin 0] [#:spacing 0]

Return a new texture atlas that splits texture into a grid of tile-width by tile-height rectangles. Optionally, each tile may have spacing pixels of horizontal and vertical space between surrounding tiles and the entire image may have margin pixels of empty space around its border.

This type of texture atlas layout is very common for 2D tile maps. See Tile Maps for more information.

Procedure: texture-atlas? obj

Return #t if obj is a texture atlas.

Procedure: texture-atlas-texture atlas

Return the texture that all texture regions in atlas have been created from.

Procedure: texture-atlas-ref atlas index

Return the texture region in atlas at index.


Next: , Up: Graphics   [Contents][Index]