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.

Texture:setPixels(source, dstx, dsty, dstlayer, dstmipmap, srcx, srcy, srclayer, srcmipmap, width, height, layers)

Arguments

NameTypeDefaultDescription
sourceTexture | Image The source texture or image to copy to this 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

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