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.
Texture:setPixels(source, dstx, dsty, dstlayer, dstmipmap, srcx, srcy, srclayer, srcmipmap, width, height, layers)Arguments
| Name | Type | Default | Description |
| source | Texture | Image | The source texture or image to copy to this 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
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.isFormatSupportedto check. - The formats do not need to match, unless they're depth formats.