Texture:setPixels

Edit

Sets pixels in the texture. The source data can be an Image with the pixels to upload, or another Texture object to copy from.



Arguments

NameTypeDefaultDescription
imageImage The image to copy to the texture.
dstxnumber0 The x offset to copy to.
dstynumber0 The y offset to copy to.
dstlayernumber1 The index of the layer to copy to.
dstmipmapnumber1 The index of the mipmap level to copy to.
srcxnumber0 The x offset to copy from.
srcynumber0 The y offset to copy from.
srclayernumber1 The index of the layer to copy from.
srcmipmapnumber1 The index of the mipmap level to copy from.
widthnumbernil 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.
heightnumbernil 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.
layersnumbernil The number of layers to copy. If nil, copies as many layers as possible.

Returns

Nothing

Arguments

NameTypeDefaultDescription
textureTexture The texture to copy from.
dstxnumber0 The x offset to copy to.
dstynumber0 The y offset to copy to.
dstlayernumber1 The index of the layer to copy to.
dstmipmapnumber1 The index of the mipmap level to copy to.
srcxnumber0 The x offset to copy from.
srcynumber0 The y offset to copy from.
srclayernumber1 The index of the layer to copy from.
srcmipmapnumber1 The index of the mipmap level to copy from.
widthnumbernil 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.
heightnumbernil 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.
layersnumbernil The number of layers to copy. If nil, copies as many layers as possible.
srcwidthnumberwidth 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.
srcheightnumberwidth 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.
srcdepthnumberlayers The depth of the region in the source texture to copy (3d textures only).
filterFilterMode'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:

See also