Browse Source

lovr.mirror;

bjorn 6 years ago
parent
commit
3e7c12a44d
2 changed files with 66 additions and 0 deletions
  1. 27 0
      api/init.lua
  2. 39 0
      api/lovr/callbacks/mirror.lua

+ 27 - 0
api/init.lua

@@ -22170,6 +22170,33 @@ return {
         }
       }
     },
+    {
+      name = "mirror",
+      tag = "callbacks",
+      summary = "Called to render content to the desktop window.",
+      description = "This callback is called every frame after rendering to the headset and is usually used to render a mirror of the headset display onto the desktop window.  It can be overridden for custom mirroring behavior.  For example, you could render a single eye instead of a stereo view, apply postprocessing effects, add 2D UI, or render the scene from an entirely different viewpoint for a third person camera.",
+      key = "lovr.mirror",
+      module = "lovr",
+      examples = {
+        {
+          description = "The default `lovr.mirror` implementation draws the headset mirror texture to the window if the headset is active, or just calls `lovr.draw` if there isn't a headset.",
+          code = "function lovr.mirror()\n  if lovr.headset then\n    local texture = lovr.headset.getMirrorTexture()\n    if texture then\n      lovr.graphics.fill(texture)\n    end\n  else\n    lovr.graphics.clear()\n    lovr.draw()\n  end\nend"
+        }
+      },
+      related = {
+        "lovr.headset.renderTo",
+        "lovr.headset.getMirrorTexture",
+        "lovr.graphics.createWindow",
+        "lovr.graphics.setProjection",
+        "lovr.draw"
+      },
+      variants = {
+        {
+          arguments = {},
+          returns = {}
+        }
+      }
+    },
     {
       name = "mount",
       tag = "callbacks",

+ 39 - 0
api/lovr/callbacks/mirror.lua

@@ -0,0 +1,39 @@
+return {
+  tag = 'callbacks',
+  summary = 'Called to render content to the desktop window.',
+  description = [[
+    This callback is called every frame after rendering to the headset and is usually used to render
+    a mirror of the headset display onto the desktop window.  It can be overridden for custom
+    mirroring behavior.  For example, you could render a single eye instead of a stereo view, apply
+    postprocessing effects, add 2D UI, or render the scene from an entirely different viewpoint for
+    a third person camera.
+  ]],
+  arguments = {},
+  returns = {},
+  example = {
+    description = [[
+      The default `lovr.mirror` implementation draws the headset mirror texture to the window if
+      the headset is active, or just calls `lovr.draw` if there isn't a headset.
+    ]],
+    code = [[
+      function lovr.mirror()
+        if lovr.headset then
+          local texture = lovr.headset.getMirrorTexture()
+          if texture then
+            lovr.graphics.fill(texture)
+          end
+        else
+          lovr.graphics.clear()
+          lovr.draw()
+        end
+      end
+    ]]
+  },
+  related = {
+    'lovr.headset.renderTo',
+    'lovr.headset.getMirrorTexture',
+    'lovr.graphics.createWindow',
+    'lovr.graphics.setProjection',
+    'lovr.draw'
+  }
+}