lovr.graphics.setBackgroundColor

Changes the global background color. The textures in a render pass will be cleared to this color at the beginning of the pass if no other clear option is specified. Additionally, the headset and window will be cleared to this color before rendering.


lovr.graphics.setBackgroundColor(r, g, b, a)

Arguments

NameTypeDefaultDescription
rnumber The red component of the background color.
gnumber The green component of the background color.
bnumber The blue component of the background color.
anumber1.0 The alpha component of the background color.

Returns

Nothing


lovr.graphics.setBackgroundColor(hex, a)

Arguments

NameTypeDefaultDescription
hexnumber A hexcode (like 0xffffff) to use for the background color (does not support alpha).
anumber1.0 The alpha component of the background color.

Returns

Nothing


lovr.graphics.setBackgroundColor(table)

Arguments

NameTypeDescription
tabletable A table containing 3 or 4 color components.

Returns

Nothing

Notes

Setting the background color in lovr.draw will apply on the following frame, since the default pass is cleared before lovr.draw is called.

Internally, this color is applied to the default pass objects when retrieving one of them using lovr.headset.getPass or lovr.graphics.getPass. Both are called automatically by the default lovr.run implementation.

Using the background color to clear the display is expected to be more efficient than manually clearing after a render pass begins, especially on mobile GPUs.

See also