Texture:setPixels
EditSets pixels in the texture. The source data can be an Image
with the pixels to upload, or another Texture
object to copy from.
Arguments
Name | Type | Default | Description |
image | Image | The image to copy to the texture. | |
dstx | number | 0 | The x offset to copy to. |
dsty | number | 0 | The y offset to copy to. |
dstlayer | number | 1 | The index of the layer to copy to. |
dstmipmap | number | 1 | The index of the mipmap level to copy to. |
srcx | number | 0 | The x offset to copy from. |
srcy | number | 0 | The y offset to copy from. |
srclayer | number | 1 | The index of the layer to copy from. |
srcmipmap | number | 1 | The index of the mipmap level to copy from. |
width | number | nil | The width of the region of pixels to copy. If nil, the maximum possible width will be used, based on the widths of the source/destination and the offset parameters. |
height | number | nil | The height of the region of pixels to copy. If nil, the maximum possible height will be used, based on the heights of the source/destination and the offset parameters. |
layers | number | nil | The number of layers to copy. If nil, copies as many layers as possible. |
Returns
Nothing
Arguments
Name | Type | Default | Description |
texture | Texture | The texture to copy from. | |
dstx | number | 0 | The x offset to copy to. |
dsty | number | 0 | The y offset to copy to. |
dstlayer | number | 1 | The index of the layer to copy to. |
dstmipmap | number | 1 | The index of the mipmap level to copy to. |
srcx | number | 0 | The x offset to copy from. |
srcy | number | 0 | The y offset to copy from. |
srclayer | number | 1 | The index of the layer to copy from. |
srcmipmap | number | 1 | The index of the mipmap level to copy from. |
width | number | nil | The width of the region of pixels to copy. If nil, the maximum possible width will be used, based on the widths of the source/destination and the offset parameters. |
height | number | nil | The height of the region of pixels to copy. If nil, the maximum possible height will be used, based on the heights of the source/destination and the offset parameters. |
layers | number | nil | The number of layers to copy. If nil, copies as many layers as possible. |
srcwidth | number | width |
The width of the region in the source texture to copy. If it doesn't match width , the copy will be scaled up or down to fit.
|
srcheight | number | width |
The height of the region in the source texture to copy. If it doesn't match height , the copy will be scaled up or down to fit.
|
srcdepth | number | layers |
The depth of the region in the source texture to copy (3d textures only).
|
filter | FilterMode | 'linear' | The filtering mode used to scale the copy when the source and destination sizes don't match. |
Returns
Nothing
Notes
Note that calling Texture:setPixels(Image)
will only update the first mipmap of the texture, leaving the other mipmaps as-is. You may want to regenerate the texture's mipmaps afterwards by calling Texture:generateMipmaps
, or disable mipmaps entirely by setting mipmaps
to false in lovr.graphics.newTexture
.
The destination and source textures must have been created with the transfer
usage.
Images can't be copied to multisample textures. Multisample textures can be copied between each other as long as there isn't any scaling.
Copying between textures requires them to have the same format.
When using different region sizes in a texture-to-texture copy:
- It is not possible to mix 3D with non-3D textures.
- Not every texture format is supported, use
lovr.graphics.isFormatSupported
to check. - The formats do not need to match, unless they're depth formats.