Browse Source

Render state docs;

bjorn 2 years ago
parent
commit
f3de1231b9

+ 2 - 0
api/lovr/graphics/Pass/push.lua

@@ -23,6 +23,8 @@ return {
   notes = [[
     Each stack has a limit of the number of copies it can store.  There can be 16 transforms and 4
     render states saved.
+
+    The `state` stack does not save the camera info or shader variables changed with `Pass:send`.
   ]],
   related = {
     'Pass:pop',

+ 2 - 1
api/lovr/graphics/Pass/setAlphaToCoverage.lua

@@ -18,5 +18,6 @@ return {
       arguments = { 'enable' },
       returns = {}
     }
-  }
+  },
+  notes = 'By default, alpha to coverage is disabled.'
 }

+ 5 - 2
api/lovr/graphics/Pass/setBlendMode.lua

@@ -1,7 +1,10 @@
 return {
   tag = 'pipeline',
   summary = 'Set the blend mode.',
-  description = 'Sets the blend mode.',
+  description = [[
+    Sets the blend mode.  When a pixel is drawn, the blend mode controls how it is mixed with the
+    color and alpha of the pixel underneath it.
+  ]],
   arguments = {
     blend = {
       type = 'BlendMode',
@@ -19,5 +22,5 @@ return {
       returns = {}
     }
   },
-  notes = 'TODO'
+  notes = 'The default blend mode is `alpha` with the `alphamultiply` alpha mode.'
 }

+ 35 - 5
api/lovr/graphics/Pass/setColor.lua

@@ -1,17 +1,47 @@
 return {
   tag = 'pipeline',
   summary = 'Set the color.',
-  description = 'TODO',
+  description = 'Sets the color used for drawing.  Color components are from 0 to 1.',
   arguments = {
-    color = {
-      type = 'Color',
-      description = 'The new color.'
+    r = {
+      type = 'number',
+      description = 'The red component of the color.'
+    },
+    g = {
+      type = 'number',
+      description = 'The green component of the color.'
+    },
+    b = {
+      type = 'number',
+      description = 'The blue component of the color.'
+    },
+    a = {
+      type = 'number',
+      default = '1.0',
+      description = 'The alpha component of the color.'
+    },
+    t = {
+      type = 'table',
+      descriptioin = 'A table of 3 or 4 color components.'
+    },
+    hex = {
+      type = 'number',
+      description = 'A hexcode.'
     }
   },
   returns = {},
+  notes = 'The default color is `(1, 1, 1, 1)`.',
   variants = {
     {
-      arguments = { 'color' },
+      arguments = { 'r', 'g', 'b', 'a' },
+      returns = {}
+    },
+    {
+      arguments = { 't' },
+      returns = {}
+    },
+    {
+      arguments = { 'hex', 'alpha' },
       returns = {}
     }
   }

+ 22 - 7
api/lovr/graphics/Pass/setColorWrite.lua

@@ -1,31 +1,46 @@
 return {
   tag = 'pipeline',
-  summary = 'Change the color components affected by drawing.',
-  description = 'TODO',
+  summary = 'Change the color channels affected by drawing.',
+  description = [[
+    Sets the color channels affected by drawing, on a per-channel basis.  Disabling color writes is
+    often used to render to the depth or stencil buffer without affecting existing pixel colors.
+  ]],
   arguments = {
     r = {
       type = 'boolean',
-      description = 'Whether the red component should be affected by drawing.'
+      description = 'Whether the red component should be affected by draws.'
     },
     g = {
       type = 'boolean',
-      description = 'Whether the green component should be affected by drawing.'
+      description = 'Whether the green component should be affected by draws.'
     },
     b = {
       type = 'boolean',
-      description = 'Whether the blue component should be affected by drawing.'
+      description = 'Whether the blue component should be affected by draws.'
     },
     a = {
       type = 'boolean',
-      description = 'Whether the alpha component should be affected by drawing.'
+      description = 'Whether the alpha component should be affected by draws.'
+    },
+    enable = {
+      type = 'boolean',
+      description = 'Whether all color components should be affected by draws.'
     }
   },
   returns = {},
   variants = {
+    {
+      arguments = { 'enable' },
+      returns = {}
+    },
     {
       arguments = { 'r', 'g', 'b', 'a' },
       returns = {}
     }
   },
-  notes = 'TODO'
+  notes = 'By default, color writes are enabled for all channels.',
+  related = {
+    'Pass:setDepthWrite',
+    'Pass:setStencilWrite'
+  }
 }

+ 2 - 2
api/lovr/graphics/Pass/setCullMode.lua

@@ -1,7 +1,7 @@
 return {
   tag = 'pipeline',
   summary = 'Control triangle face culling.',
-  description = 'TODO',
+  description = 'Sets whether the front or back faces of triangles are culled.',
   arguments = {
     mode = {
       type = 'CullMode',
@@ -16,7 +16,7 @@ return {
       returns = {}
     }
   },
-  notes = 'TODO',
+  notes = 'The default cull mode is `none`.',
   related = {
     'Pass:setWinding'
   }

+ 9 - 5
api/lovr/graphics/Pass/setDepthWrite.lua

@@ -1,11 +1,15 @@
 return {
   tag = 'pipeline',
   summary = 'Set whether draws write to the depth buffer.',
-  description = 'TODO',
+  description = [[
+    Sets whether draws write to the depth buffer.  When a pixel is drawn, if depth writes are
+    enabled and the pixel passes the depth test, the depth buffer will be updated with the pixel's
+    depth value.
+  ]],
   arguments = {
     write = {
       type = 'boolean',
-      description = 'The new depth write setting.'
+      description = 'Whether the depth buffer should be affected by draws.'
     }
   },
   returns = {},
@@ -15,10 +19,10 @@ return {
       returns = {}
     }
   },
-  notes = 'TODO',
+  notes = 'The default depth write is `true`.',
   related = {
-    'Pass:setDepthTest',
     'Pass:setStencilWrite',
-    'Pass:setColorWrite'
+    'Pass:setColorWrite',
+    'Pass:setDepthTest'
   }
 }

+ 5 - 3
api/lovr/graphics/Pass/setFont.lua

@@ -1,7 +1,7 @@
 return {
   tag = 'pipeline',
-  summary = 'Enable or disable depth clamp.',
-  description = 'TODO',
+  summary = 'Set the font.',
+  description = 'Sets the font used for `Pass:text`.',
   arguments = {
     font = {
       type = 'Font',
@@ -16,6 +16,8 @@ return {
     }
   },
   related = {
-    'Pass:text'
+    'Pass:text',
+    'lovr.graphics.newFont',
+    'lovr.graphics.getDefaultFont'
   }
 }

+ 7 - 2
api/lovr/graphics/Pass/setWinding.lua

@@ -1,7 +1,10 @@
 return {
   tag = 'pipeline',
   summary = 'Set the winding direction of triangle vertices.',
-  description = 'TODO',
+  description = [[
+    Sets whether vertices in the clockwise or counterclockwise order vertices are considered the
+    "front" face of a triangle.  This is used for culling with `Pass:setCullMode`.
+  ]],
   arguments = {
     winding = {
       type = 'Winding',
@@ -15,7 +18,9 @@ return {
       returns = {}
     }
   },
-  notes = 'TODO',
+  notes = [[
+    The default winding is counterclockwise.  LÖVR's builtin shapes are wound counterclockwise.
+  ]],
   related = {
     'Pass:setCullMode'
   }

+ 3 - 2
api/lovr/graphics/Shader/getType.lua

@@ -1,6 +1,6 @@
 return {
   summary = 'Get the type of the Shader.',
-  description = 'TODO',
+  description = 'Returns whether the shader is a graphics or compute shader.',
   arguments = {},
   returns = {
     type = {
@@ -15,6 +15,7 @@ return {
     }
   },
   related = {
-    'Shader:hasStage'
+    'Shader:hasStage',
+    'lovr.graphics.newShader'
   }
 }

+ 8 - 3
api/lovr/graphics/StackType.lua

@@ -1,14 +1,19 @@
 return {
   summary = 'Types of stacks that can be pushed and popped.',
-  description = 'TODO',
+  description = [[
+    Different types of stacks that can be pushed and popped with `Pass:push` and `Pass:pop`.
+  ]],
   values = {
     {
       name = 'transform',
-      description = 'TODO'
+      description = 'The transform stack (`Pass:transform`, `Pass:translate`, etc.).'
     },
     {
       name = 'state',
-      description = 'TODO'
+      description = [[
+        Graphics state, like `Pass:setColor`, `Pass:setFont`, etc.  Notably this does not include
+        camera poses/projections or shader variables changed with `Pass:send`.
+      ]]
     }
   }
 }