Browse Source

DepthFormat;

bjorn 6 years ago
parent
commit
85d491eaf2

+ 0 - 16
api/lovr/graphics/Canvas/getDepthFormat.lua

@@ -1,16 +0,0 @@
-return {
-  summary = 'Get the format of the Canvas depth buffer.',
-  description = 'Returns the format of the Canvas depth buffer.',
-  arguments = {},
-  returns = {
-    {
-      name = 'format',
-      type = 'DepthFormat',
-      description = 'The format of the Canvas depth buffer.'
-    }
-  },
-  related = {
-    'lovr.graphics.newCanvas',
-    'DepthFormat'
-  }
-}

+ 19 - 0
api/lovr/graphics/Canvas/getDepthTexture.lua

@@ -0,0 +1,19 @@
+return {
+  summary = 'Get the depth buffer used by the Canvas.',
+  description = [[
+    Returns the depth buffer used by the Canvas as a Texture.  If the Canvas was not created with a
+    readable depth buffer (the `depth.readable` flag in `lovr.graphics.newCanvas`), then this
+    function will return `nil`.
+  ]],
+  arguments = {},
+  returns = {
+    {
+      name = 'texture',
+      type = 'Texture',
+      description = 'The depth Texture of the Canvas.'
+    }
+  },
+  related = {
+    'lovr.graphics.newCanvas'
+  }
+}

+ 0 - 31
api/lovr/graphics/DepthFormat.lua

@@ -1,31 +0,0 @@
-return {
-  summary = 'Different types of depth maps used by Canvases.',
-  description = [[
-    When you create a Canvas, you can give it a depth buffer, which stores the 3D positions of
-    pixels to ensure that the depth of objects is sorted properly.  This depth information can be
-    stored in various formats that differ in size and precision.  Additionally, this depth buffer
-    can also be used for stenciling information.
-  ]],
-  values = {
-    {
-      name = 'd16',
-      description = 'A 16 bit depth buffer.'
-    },
-    {
-      name = 'd32f',
-      description = 'A 32 bit floating point depth buffer.'
-    },
-    {
-      name = 'd24s8',
-      description = 'A depth buffer with 24 bits for depth and 8 bits for stencil.'
-    }
-  },
-  related = {
-    'lovr.graphics.newCanvas',
-    'Canvas:getDepthFormat',
-    'lovr.graphics.getDepthTest',
-    'lovr.graphics.setDepthTest',
-    'lovr.graphics.stencil',
-    'Canvas'
-  }
-}

+ 12 - 0
api/lovr/graphics/TextureFormat.lua

@@ -53,6 +53,18 @@ return {
     {
       name = 'rg11b10f',
       description = 'Each pixel is 32 bits, and packs three color channels into 10 or 11 bits each.'
+    },
+    {
+      name = 'd16',
+      description = 'A 16 bit depth buffer.'
+    },
+    {
+      name = 'd32f',
+      description = 'A 32 bit floating point depth buffer.'
+    },
+    {
+      name = 'd24s8',
+      description = 'A depth buffer with 24 bits for depth and 8 bits for stencil.'
     }
   }
 }

+ 3 - 2
api/lovr/graphics/newCanvas.lua

@@ -41,10 +41,11 @@ return {
         },
         {
           name = 'depth',
-          type = 'DepthFormat',
+          type = 'TextureFormat',
           default = 'd16',
           description = [[
-            A DepthFormat to use for the Canvas depth buffer, or false for no depth buffer.
+            A depth TextureFormat to use for the Canvas depth buffer, or false for no depth buffer.
+            Note that this can also be a table with `format` and `readable` keys.
           ]]
         },
         {