lovr.graphics.newTexture

Creates a new Texture from an image file.

texture = lovr.graphics.newTexture(filename, flags)

Arguments

NameTypeDefaultDescription
filenamestringThe filename of the image to load.
flagstable{}Optional settings for the texture.
.linearbooleanfalseWhether the texture is in linear color space instead of the usual sRGB.
.mipmapsbooleantrueWhether mipmaps will be generated for the texture.
.typeTextureTypenilThe type of Texture to load the images into. If nil, the type will be 2d for a single image, array for a table of images with numeric keys, or cube for a table of images with string keys.
.formatTextureFormatrgbaThe format used for the Texture (when creating a blank texture).
.msaanumber0The antialiasing level to use (when attaching the Texture to a Canvas).

Returns

NameTypeDescription
textureTextureThe new Texture.

Create a Texture from a table of filenames, Blobs, or TextureData. For cube textures, the individual faces can be specified using the string keys "right", "left", "top", "bottom", "back", "front".

texture = lovr.graphics.newTexture(images, flags)

Arguments

NameTypeDefaultDescription
imagestable
flagstable{}Optional settings for the texture.
.linearbooleanfalseWhether the texture is in linear color space instead of the usual sRGB.
.mipmapsbooleantrueWhether mipmaps will be generated for the texture.
.typeTextureTypenilThe type of Texture to load the images into. If nil, the type will be 2d for a single image, array for a table of images with numeric keys, or cube for a table of images with string keys.
.formatTextureFormatrgbaThe format used for the Texture (when creating a blank texture).
.msaanumber0The antialiasing level to use (when attaching the Texture to a Canvas).

Returns

NameTypeDescription
textureTextureThe new Texture.

Creates a blank Texture with specified dimensions. This saves memory if you're planning on rendering to the Texture using a Canvas or a compute shader, but the contents of the Texture will be initialized to random data.

texture = lovr.graphics.newTexture(width, height, depth, flags)

Arguments

NameTypeDefaultDescription
widthnumberThe width of the Texture.
heightnumberThe height of the Texture.
depthnumberThe depth of the Texture.
flagstable{}Optional settings for the texture.
.linearbooleanfalseWhether the texture is in linear color space instead of the usual sRGB.
.mipmapsbooleantrueWhether mipmaps will be generated for the texture.
.typeTextureTypenilThe type of Texture to load the images into. If nil, the type will be 2d for a single image, array for a table of images with numeric keys, or cube for a table of images with string keys.
.formatTextureFormatrgbaThe format used for the Texture (when creating a blank texture).
.msaanumber0The antialiasing level to use (when attaching the Texture to a Canvas).

Returns

NameTypeDescription
textureTextureThe new Texture.

Create a texture from a single Blob.

texture = lovr.graphics.newTexture(blob, flags)

Arguments

NameTypeDefaultDescription
blobBlobThe Blob containing encoded image data used to create the Texture.
flagstable{}Optional settings for the texture.
.linearbooleanfalseWhether the texture is in linear color space instead of the usual sRGB.
.mipmapsbooleantrueWhether mipmaps will be generated for the texture.
.typeTextureTypenilThe type of Texture to load the images into. If nil, the type will be 2d for a single image, array for a table of images with numeric keys, or cube for a table of images with string keys.
.formatTextureFormatrgbaThe format used for the Texture (when creating a blank texture).
.msaanumber0The antialiasing level to use (when attaching the Texture to a Canvas).

Returns

NameTypeDescription
textureTextureThe new Texture.

Create a texture from a single TextureData.

texture = lovr.graphics.newTexture(textureData, flags)

Arguments

NameTypeDefaultDescription
textureDataTextureDataThe TextureData to create the Texture from.
flagstable{}Optional settings for the texture.
.linearbooleanfalseWhether the texture is in linear color space instead of the usual sRGB.
.mipmapsbooleantrueWhether mipmaps will be generated for the texture.
.typeTextureTypenilThe type of Texture to load the images into. If nil, the type will be 2d for a single image, array for a table of images with numeric keys, or cube for a table of images with string keys.
.formatTextureFormatrgbaThe format used for the Texture (when creating a blank texture).
.msaanumber0The antialiasing level to use (when attaching the Texture to a Canvas).

Returns

NameTypeDescription
textureTextureThe new Texture.

Notes

The "linear" flag should be set to true for textures that don't contain color information, such as normal maps.

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

See also