mirror.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. return {
  2. tag = 'callbacks',
  3. summary = 'Called to render content to the desktop window.',
  4. description = [[
  5. This callback is called every frame after rendering to the headset and is usually used to render
  6. a mirror of the headset display onto the desktop window. It can be overridden for custom
  7. mirroring behavior. For example, you could render a single eye instead of a stereo view, apply
  8. postprocessing effects, add 2D UI, or render the scene from an entirely different viewpoint for
  9. a third person camera.
  10. ]],
  11. arguments = {},
  12. returns = {},
  13. notes = [[
  14. When this callback is called, the camera is located at `(0, 0, 0)` and is looking down the
  15. negative-z axis.
  16. Note that the usual graphics state applies while `lovr.mirror` is invoked, so you may need to
  17. reset graphics state at the end of `lovr.draw` to get the result you want.
  18. ]],
  19. example = {
  20. description = [[
  21. The default `lovr.mirror` implementation draws the headset mirror texture to the window if
  22. the headset is active, or just calls `lovr.draw` if there isn't a headset.
  23. ]],
  24. code = [[
  25. function lovr.mirror()
  26. if lovr.headset then
  27. local texture = lovr.headset.getMirrorTexture()
  28. if texture then
  29. lovr.graphics.fill(texture)
  30. end
  31. else
  32. lovr.graphics.clear()
  33. lovr.draw()
  34. end
  35. end
  36. ]]
  37. },
  38. related = {
  39. 'lovr.headset.renderTo',
  40. 'lovr.headset.getMirrorTexture',
  41. 'lovr.graphics.createWindow',
  42. 'lovr.graphics.setProjection',
  43. 'lovr.draw'
  44. }
  45. }