lovr.graphics.newTexture
Creates a new Texture from an image file.
texture = lovr.graphics.newTexture(filename, flags)
Arguments
Name | Type | Default | Description |
filename | string | | The filename of the image to load.
|
flags | table | {} | Optional settings for the texture.
|
.linear | boolean | false | Whether the texture is in linear color space instead of the usual sRGB.
|
.mipmaps | boolean | true | Whether mipmaps will be generated for the texture.
|
.type | TextureType | nil | The 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.
|
.format | TextureFormat | 'rgba' | The format used for the Texture (when creating a blank texture).
|
.msaa | number | 0 | The antialiasing level to use (when attaching the Texture to a Canvas).
|
Returns
Name | Type | Description |
texture | Texture | The 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
Name | Type | Default | Description |
images | table | | A table of image filenames to load.
|
flags | table | {} | Optional settings for the texture.
|
.linear | boolean | false | Whether the texture is in linear color space instead of the usual sRGB.
|
.mipmaps | boolean | true | Whether mipmaps will be generated for the texture.
|
.type | TextureType | nil | The 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.
|
.format | TextureFormat | 'rgba' | The format used for the Texture (when creating a blank texture).
|
.msaa | number | 0 | The antialiasing level to use (when attaching the Texture to a Canvas).
|
Returns
Name | Type | Description |
texture | Texture | The 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
Name | Type | Default | Description |
width | number | | The width of the Texture.
|
height | number | | The height of the Texture.
|
depth | number | | The depth of the Texture.
|
flags | table | {} | Optional settings for the texture.
|
.linear | boolean | false | Whether the texture is in linear color space instead of the usual sRGB.
|
.mipmaps | boolean | true | Whether mipmaps will be generated for the texture.
|
.type | TextureType | nil | The 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.
|
.format | TextureFormat | 'rgba' | The format used for the Texture (when creating a blank texture).
|
.msaa | number | 0 | The antialiasing level to use (when attaching the Texture to a Canvas).
|
Returns
Name | Type | Description |
texture | Texture | The new Texture.
|
Create a texture from a single Blob.
texture = lovr.graphics.newTexture(blob, flags)
Arguments
Name | Type | Default | Description |
blob | Blob | | The Blob containing encoded image data used to create the Texture.
|
flags | table | {} | Optional settings for the texture.
|
.linear | boolean | false | Whether the texture is in linear color space instead of the usual sRGB.
|
.mipmaps | boolean | true | Whether mipmaps will be generated for the texture.
|
.type | TextureType | nil | The 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.
|
.format | TextureFormat | 'rgba' | The format used for the Texture (when creating a blank texture).
|
.msaa | number | 0 | The antialiasing level to use (when attaching the Texture to a Canvas).
|
Returns
Name | Type | Description |
texture | Texture | The new Texture.
|
Create a texture from a single TextureData.
texture = lovr.graphics.newTexture(textureData, flags)
Arguments
Name | Type | Default | Description |
textureData | TextureData | | The TextureData to create the Texture from.
|
flags | table | {} | Optional settings for the texture.
|
.linear | boolean | false | Whether the texture is in linear color space instead of the usual sRGB.
|
.mipmaps | boolean | true | Whether mipmaps will be generated for the texture.
|
.type | TextureType | nil | The 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.
|
.format | TextureFormat | 'rgba' | The format used for the Texture (when creating a blank texture).
|
.msaa | number | 0 | The antialiasing level to use (when attaching the Texture to a Canvas).
|
Returns
Name | Type | Description |
texture | Texture | The 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