setBackgroundColor.lua 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. return {
  2. tag = 'graphics-global',
  3. summary = 'Set the background color.',
  4. description = [[
  5. Changes the global background color. The textures in a render pass will be cleared to this
  6. color at the beginning of the pass if no other clear option is specified. Additionally, the
  7. headset and window will be cleared to this color before rendering.
  8. ]],
  9. arguments = {
  10. r = {
  11. type = 'number',
  12. description = 'The red component of the background color.',
  13. },
  14. g = {
  15. type = 'number',
  16. description = 'The green component of the background color.',
  17. },
  18. b = {
  19. type = 'number',
  20. description = 'The blue component of the background color.',
  21. },
  22. a = {
  23. default = '1.0',
  24. type = 'number',
  25. description = 'The alpha component of the background color.',
  26. },
  27. hex = {
  28. type = 'number',
  29. description = [[
  30. A hexcode (like `0xffffff`) to use for the background color (does not support alpha).
  31. ]]
  32. },
  33. table = {
  34. type = 'table',
  35. description = 'A table containing 3 or 4 color components.'
  36. }
  37. },
  38. returns = {},
  39. variants = {
  40. {
  41. arguments = { 'r', 'g', 'b', 'a' },
  42. returns = {}
  43. },
  44. {
  45. arguments = { 'hex', 'a' },
  46. returns = {}
  47. },
  48. {
  49. arguments = { 'table' },
  50. returns = {}
  51. }
  52. },
  53. notes = [[
  54. Setting the background color in `lovr.draw` will apply on the following frame, since the default
  55. pass is cleared before `lovr.draw` is called.
  56. Internally, this color is applied to the default pass objects when retrieving one of them using
  57. `lovr.headset.getPass` or `lovr.graphics.getWindowPass`. Both are called automatically by the
  58. default `lovr.run` implementation.
  59. Using the background color to clear the display is expected to be more efficient than manually
  60. clearing after a render pass begins, especially on mobile GPUs.
  61. ]],
  62. related = {
  63. 'lovr.graphics.newPass',
  64. 'Pass:setClear',
  65. 'Texture:clear',
  66. 'Pass:fill'
  67. }
  68. }