textures
Canonical Import
fennel
(local textures (require :textures))Source Files
src/lua_textures.cppsrc/image_loader.cppassets/lua/tests/test-jpeg-texture-decode.fnl
What It Provides
textures manages OpenGL texture resources through the Space resource manager. It can load textures from paths, decoded image bytes, raw pixel bytes, and cubemap face files.
API Summary
load-texture(name path)andload-texture-async(name path [callback])load image files intoTexture2Dresources.load-texture-from-bytes(name bytes [already-flipped?])andload-texture-from-bytes-async(name bytes [already-flipped?] [callback])decode image bytes in memory and create textures.load-texture-from-pixels(name width height channels bytes [already-flipped?])creates a texture from raw pixel bytes.allocate-texture(name width height channels),get-texture(name), anddrop-texture(name)manage named texture resources.load-cubemap(files)andload-cubemap-async(files [callback])load cubemap faces.Texture2Dexposesid,width,height,n,ready, wrapping/filter fields,load,allocate,generate,update-full,update-sub-rect, andsetActive.TextureCubemapexposesid,ready,load-faces, anddrop.
Examples
fennel
(local textures (require :textures))
(local tex (textures.load-texture :logo "assets/images/logo.png"))
(when tex.ready
(tex:setActive))Errors and Platform Notes
Decode failures raise errors such as Failed to decode texture bytes. Dimensions and channel counts must be positive, and raw pixel buffers must contain enough bytes. JPEG/JPG decoding is available through the texture/image loader path, but jpeg and jpg are search terms, not importable module names.
Related Modules
image-iofor PNG read/write and byte flipping utilities.glfor binding and drawing with texture IDs.
Aliases and Search Terms
Search terms: texture, Texture2D, cubemap, image texture, jpeg, jpg, PNG, graphics, rendering.
