lovr.graphics.newCanvas

Creates a new Canvas. You can specify Textures to attach to it, or just specify a width and height and attach textures later using Canvas:setTexture.

Once created, you can render to the Canvas using Canvas:renderTo, or lovr.graphics.setCanvas.

Create an empty Canvas with no Textures attached.

canvas = lovr.graphics.newCanvas(width, height, flags)

Arguments

NameTypeDefaultDescription
widthnumberThe width of the canvas, in pixels.
heightnumberThe height of the canvas, in pixels.
flagstable{}Optional settings for the Canvas.
.formatTextureFormat'rgba'The format of a Texture to create and attach to this Canvas, or false if no Texture should be created. This is ignored if Textures are already passed in.
.depthTextureFormatd16A depth TextureFormat to use for the Canvas depth buffer, or false for no depth buffer. Note that this can also be a table with format and readable keys.
.stereobooleantrueWhether the Canvas is stereo.
.msaanumber0The number of MSAA samples to use for antialiasing.
.mipmapsbooleantrueWhether the Canvas will automatically generate mipmaps for its attached textures.

Returns

NameTypeDescription
canvasCanvasThe new Canvas.

Create a Canvas with attached Textures.

canvas = lovr.graphics.newCanvas(..., flags)

Arguments

NameTypeDefaultDescription
...TextureOne or more Textures to attach to the Canvas.
flagstable{}Optional settings for the Canvas.
.formatTextureFormat'rgba'The format of a Texture to create and attach to this Canvas, or false if no Texture should be created. This is ignored if Textures are already passed in.
.depthTextureFormatd16A depth TextureFormat to use for the Canvas depth buffer, or false for no depth buffer. Note that this can also be a table with format and readable keys.
.stereobooleantrueWhether the Canvas is stereo.
.msaanumber0The number of MSAA samples to use for antialiasing.
.mipmapsbooleantrueWhether the Canvas will automatically generate mipmaps for its attached textures.

Returns

NameTypeDescription
canvasCanvasThe new Canvas.

Create a Canvas with attached Textures, using specific layers and mipmap levels from each one. Layers and mipmaps can be specified after each Texture as numbers, or a table of a Texture, layer, and mipmap can be used for each attachment.

canvas = lovr.graphics.newCanvas(attachments, flags)

Arguments

NameTypeDefaultDescription
attachmentstableA table of textures, layers, and mipmaps (in any combination) to attach.
flagstable{}Optional settings for the Canvas.
.formatTextureFormat'rgba'The format of a Texture to create and attach to this Canvas, or false if no Texture should be created. This is ignored if Textures are already passed in.
.depthTextureFormatd16A depth TextureFormat to use for the Canvas depth buffer, or false for no depth buffer. Note that this can also be a table with format and readable keys.
.stereobooleantrueWhether the Canvas is stereo.
.msaanumber0The number of MSAA samples to use for antialiasing.
.mipmapsbooleantrueWhether the Canvas will automatically generate mipmaps for its attached textures.

Returns

NameTypeDescription
canvasCanvasThe new Canvas.

Notes

Textures created by this function will have clamp as their TextureWrap.

See also