draw.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. return {
  2. tag = 'callbacks',
  3. summary = 'Called continuously to render frames to the display.',
  4. description = [[
  5. This callback is called every frame, and receives a `Pass` object as an argument which can be
  6. used to render graphics to the display. If a VR headset is connected, this function renders to
  7. the headset display, otherwise it will render to the desktop window.
  8. ]],
  9. arguments = {
  10. pass = {
  11. type = 'Pass',
  12. description = 'A render pass targeting the main display (headset or window).'
  13. }
  14. },
  15. returns = {
  16. skip = {
  17. type = 'boolean | nil',
  18. description = 'If truthy, the input Pass will not be submitted to the GPU.'
  19. }
  20. },
  21. variants = {
  22. {
  23. arguments = { 'pass' },
  24. returns = { 'skip' }
  25. }
  26. },
  27. notes = [[
  28. To render to the desktop window when a VR headset is connected, use the `lovr.mirror` callback.
  29. The display is cleared to the global background color before this callback is called, which can
  30. be changed using `lovr.graphics.setBackgroundColor`.
  31. Since the `lovr.graphics.submit` function always returns true, the following idiom can be used
  32. to submit graphics work manually and override the default submission:
  33. function lovr.draw(pass)
  34. local passes = {}
  35. -- ... record multiple passes and add to passes table
  36. return lovr.graphics.submit(passes)
  37. end
  38. ]],
  39. related = {
  40. 'lovr.mirror',
  41. 'lovr.headset.getPass',
  42. 'lovr.graphics.getWindowPass',
  43. 'lovr.graphics.setBackgroundColor'
  44. }
  45. }