lovr.data.newTextureData

Creates a new TextureData. Image data can be loaded and decoded from an image file, or a raw block of pixels with a specified width, height, and format can be created.

Load image data from a file.

textureData = lovr.data.newTextureData(filename, flip)

Arguments

NameTypeDefaultDescription
filenamestringThe filename of the image to load.
flipbooleantrueWhether to vertically flip the image on load. This should be true for normal textures, and false for textures that are going to be used in a cubemap.

Returns

NameTypeDescription
textureDataTextureDataThe new TextureData.

Create an empty TextureData, initializing all pixel values to 0 (transparent black).

textureData = lovr.data.newTextureData(width, height, format)

Arguments

NameTypeDefaultDescription
widthnumberThe width of the texture.
heightnumberThe height of the texture.
formatTextureFormatrgbaThe format of the texture's pixels.

Returns

NameTypeDescription
textureDataTextureDataThe new TextureData.

Decode image data from a Blob.

textureData = lovr.data.newTextureData(blob, flip)

Arguments

NameTypeDefaultDescription
blobBlobThe Blob containing image data to decode.
flipbooleantrueWhether to vertically flip the image on load. This should be true for normal textures, and false for textures that are going to be used in a cubemap.

Returns

NameTypeDescription
textureDataTextureDataThe new TextureData.

Notes

Right now the supported image file formats are png, jpg, hdr, dds (DXT1, DXT3, DXT5), ktx, and astc.

See also