Browse Source

Some graphics docs;

bjorn 5 years ago
parent
commit
d4eda392a8

+ 92 - 213
api/init.lua

@@ -6278,46 +6278,69 @@ return {
             {
               arguments = {
                 {
-                  name = "width",
-                  type = "number",
-                  description = "The width of the window.",
-                  default = "1080"
-                },
-                {
-                  name = "height",
-                  type = "number",
-                  description = "The height of the window.",
-                  default = "600"
-                },
-                {
-                  name = "fullscreen",
-                  type = "boolean",
-                  description = "Whether the window should be fullscreen.",
-                  default = "false"
-                },
-                {
-                  name = "msaa",
-                  type = "number",
-                  description = "The number of samples to use for multisample antialiasing.",
-                  default = "0"
-                },
-                {
-                  name = "title",
-                  type = "string",
-                  description = "The window title.",
-                  default = "nil"
-                },
-                {
-                  name = "icon",
-                  type = "string",
-                  description = "A path to an image to use for the window icon.",
-                  default = "nil"
+                  name = "flags",
+                  type = "table",
+                  description = "Flags to customize the window's appearance and behavior.",
+                  table = {
+                    {
+                      name = "width",
+                      type = "number",
+                      description = "The width of the window, or 0 to use the size of the monitor.",
+                      default = "1080"
+                    },
+                    {
+                      name = "height",
+                      type = "number",
+                      description = "The height of the window, or 0 to use the size of the monitor.",
+                      default = "600"
+                    },
+                    {
+                      name = "fullscreen",
+                      type = "boolean",
+                      description = "Whether the window should be fullscreen.",
+                      default = "false"
+                    },
+                    {
+                      name = "resizable",
+                      type = "boolean",
+                      description = "Whether the window should be resizable.",
+                      default = "false"
+                    },
+                    {
+                      name = "msaa",
+                      type = "number",
+                      description = "The number of samples to use for multisample antialiasing.",
+                      default = "0"
+                    },
+                    {
+                      name = "title",
+                      type = "string",
+                      description = "The window title.",
+                      default = "LÖVR"
+                    },
+                    {
+                      name = "icon",
+                      type = "string",
+                      description = "A path to an image to use for the window icon.",
+                      default = "nil"
+                    },
+                    {
+                      name = "vsync",
+                      type = "number",
+                      description = "0 to disable vsync, 1 to enable.  This is only a hint, and may not be respected if necessary for the current VR display.",
+                      default = "0"
+                    }
+                  }
                 }
               },
               returns = {}
             }
           },
-          notes = "This function can only be called once. It is normally called internally, but you can override this by setting window to `nil` in conf.lua.  See `lovr.conf` for more information."
+          related = {
+            "lovr.graphics.hasWindow",
+            "lovr.conf"
+          },
+          notes = "This function can only be called once.  It is normally called internally, but you can override this by setting window to `nil` in conf.lua.  See `lovr.conf` for more information.\n\nThe window must be created before any `lovr.graphics` functions can be used."
         },
         {
           name = "cube",
@@ -6687,10 +6710,10 @@ return {
           description = "Draws a fullscreen textured quad.",
           key = "lovr.graphics.fill",
           module = "lovr.graphics",
-          notes = "This function ignores stereo rendering, so it will stretch the input across the entire Canvas if it's stereo.",
+          notes = "This function ignores stereo rendering, so it will stretch the input across the entire Canvas if it's stereo.  Special shaders are currently required for correct stereo fills.",
           variants = {
             {
-              description = "Fills the screen with a Texture.",
+              description = "Fills the screen with a region of a Texture.",
               arguments = {
                 {
                   name = "texture",
@@ -6724,41 +6747,6 @@ return {
               },
               returns = {}
             },
-            {
-              description = "Fills the screen with the first Texture attached to a Canvas.",
-              arguments = {
-                {
-                  name = "canvas",
-                  type = "Canvas",
-                  description = "The first Texture attached to this Canvas will be used."
-                },
-                {
-                  name = "u",
-                  type = "number",
-                  description = "The x component of the uv offset.",
-                  default = "0"
-                },
-                {
-                  name = "v",
-                  type = "number",
-                  description = "The y component of the uv offset.",
-                  default = "0"
-                },
-                {
-                  name = "w",
-                  type = "number",
-                  description = "The width of the Texture to render, in uv coordinates.",
-                  default = "1 - u"
-                },
-                {
-                  name = "h",
-                  type = "number",
-                  description = "The height of the Texture to render, in uv coordinates.",
-                  default = "1 - v"
-                }
-              },
-              returns = {}
-            },
             {
               description = "Fills the screen with the active color.",
               arguments = {},
@@ -6787,7 +6775,7 @@ return {
         {
           name = "getAlphaSampling",
           tag = "graphicsState",
-          summary = "Get whether alpha sampling (alpha to coverage) is enabled.",
+          summary = "Get whether alpha sampling is enabled.",
           description = "Returns whether or not alpha sampling is enabled.  Alpha sampling is also known as alpha-to-coverage.  When it is enabled, the alpha channel of a pixel is factored into how antialiasing is computed, so the edges of a transparent texture will be correctly antialiased.",
           key = "lovr.graphics.getAlphaSampling",
           module = "lovr.graphics",
@@ -6803,7 +6791,7 @@ return {
               }
             }
           },
-          notes = "- Alpha sampling is disabled by default.\n- This feature can be used for a cheap transparency effect, pixels with an alpha of zero will\n  have their depth value discarded, allowing things behind them to show through (normally you\n  have to sort objects or write a shader for this)."
+          notes = "- Alpha sampling is disabled by default.\n- This feature can be used for a simple transparency effect, pixels with an alpha of zero will\n  have their depth value discarded, allowing things behind them to show through (normally you\n  have to sort objects or write a shader for this)."
         },
         {
           name = "getBackgroundColor",
@@ -6839,7 +6827,7 @@ return {
               }
             }
           },
-          notes = "The default background color is black."
+          notes = "The default background color is `(0.0, 0.0, 0.0, 1.0)`."
         },
         {
           name = "getBlendMode",
@@ -6929,7 +6917,7 @@ return {
               }
             }
           },
-          notes = "The default color is white."
+          notes = "The default color is `(1.0, 1.0, 1.0, 1.0)`."
         },
         {
           name = "getDefaultFilter",
@@ -6995,7 +6983,8 @@ return {
           module = "lovr.graphics",
           related = {
             "lovr.graphics.getWidth",
-            "lovr.graphics.getHeight"
+            "lovr.graphics.getHeight",
+            "lovr.graphics.getPixelDensity"
           },
           variants = {
             {
@@ -7102,7 +7091,8 @@ return {
           module = "lovr.graphics",
           related = {
             "lovr.graphics.getWidth",
-            "lovr.graphics.getDimensions"
+            "lovr.graphics.getDimensions",
+            "lovr.graphics.getPixelDensity"
           },
           variants = {
             {
@@ -7333,7 +7323,8 @@ return {
           module = "lovr.graphics",
           related = {
             "lovr.graphics.getHeight",
-            "lovr.graphics.getDimensions"
+            "lovr.graphics.getDimensions",
+            "lovr.graphics.getPixelDensity"
           },
           variants = {
             {
@@ -7380,10 +7371,6 @@ return {
           description = "Returns whether the desktop window is currently created.",
           key = "lovr.graphics.hasWindow",
           module = "lovr.graphics",
-          related = {
-            "lovr.graphics.createWindow",
-            "lovr.conf"
-          },
           variants = {
             {
               arguments = {},
@@ -7395,7 +7382,12 @@ return {
                 }
               }
             }
-          }
+          },
+          related = {
+            "lovr.graphics.createWindow",
+            "lovr.conf"
+          },
+          notes = "Most of the `lovr.graphics` functionality will only work if a window is created."
         },
         {
           name = "isCullingEnabled",
@@ -8092,34 +8084,6 @@ return {
                   name = "filename",
                   type = "string",
                   description = "The filename of the model to load."
-                },
-                {
-                  name = "texture",
-                  type = "string",
-                  description = "The filename of the texture to apply to the model.",
-                  default = "nil"
-                }
-              },
-              returns = {
-                {
-                  name = "model",
-                  type = "Model",
-                  description = "The new Model."
-                }
-              }
-            },
-            {
-              arguments = {
-                {
-                  name = "filename",
-                  type = "string",
-                  description = "The filename of the model to load."
-                },
-                {
-                  name = "material",
-                  type = "Material",
-                  description = "The material to apply to the model.  If nil, the materials will be loaded from the model file.",
-                  default = "nil"
                 }
               },
               returns = {
@@ -8135,35 +8099,7 @@ return {
                 {
                   name = "modelData",
                   type = "ModelData",
-                  description = "The ModelData holding the data for the Model."
-                },
-                {
-                  name = "texture",
-                  type = "string",
-                  description = "The filename of the texture to apply to the model.",
-                  default = "nil"
-                }
-              },
-              returns = {
-                {
-                  name = "model",
-                  type = "Model",
-                  description = "The new Model."
-                }
-              }
-            },
-            {
-              arguments = {
-                {
-                  name = "modelData",
-                  type = "ModelData",
-                  description = "The ModelData holding the data for the Model."
-                },
-                {
-                  name = "material",
-                  type = "Material",
-                  description = "The material to apply to the model.  If nil, the materials will be loaded from the model file.",
-                  default = "nil"
+                  description = "The ModelData containing the data for the Model."
                 }
               },
               returns = {
@@ -8898,7 +8834,7 @@ return {
           name = "reset",
           tag = "graphicsState",
           summary = "Reset all graphics state.",
-          description = "Resets the graphics state.  This includes the coordinate transformation, projection, shader, colors, scissor, and culling state.",
+          description = "Resets all graphics state to the initial values.",
           key = "lovr.graphics.reset",
           module = "lovr.graphics",
           variants = {
@@ -8921,7 +8857,8 @@ return {
                 {
                   name = "angle",
                   type = "number",
-                  description = "The amount to rotate the coordinate system by, in radians."
+                  description = "The amount to rotate the coordinate system by, in radians.",
+                  default = "0"
                 },
                 {
                   name = "ax",
@@ -8965,7 +8902,8 @@ return {
                 {
                   name = "x",
                   type = "number",
-                  description = "The amount to scale on the x axis."
+                  description = "The amount to scale on the x axis.",
+                  default = "1.0"
                 },
                 {
                   name = "y",
@@ -9009,7 +8947,7 @@ return {
               returns = {}
             }
           },
-          notes = "- Alpha sampling is disabled by default.\n- This feature can be used for a cheap transparency effect, pixels with an alpha of zero will\n  have their depth value discarded, allowing things behind them to show through (normally you\n  have to sort objects or write a shader for this)."
+          notes = "- Alpha sampling is disabled by default.\n- This feature can be used for a simple transparency effect, pixels with an alpha of zero will\n  have their depth value discarded, allowing things behind them to show through (normally you\n  have to sort objects or write a shader for this)."
         },
         {
           name = "setBackgroundColor",
@@ -9018,7 +8956,7 @@ return {
           description = "Sets the background color used to clear the screen.  Color components are from 0.0 to 1.0.",
           key = "lovr.graphics.setBackgroundColor",
           module = "lovr.graphics",
-          notes = "The default background color is `(0, 0, 0, 1)`.",
+          notes = "The default background color is `(0.0, 0.0, 0.0, 1.0)`.",
           variants = {
             {
               arguments = {
@@ -9135,7 +9073,7 @@ return {
           description = "Sets the color used for drawing objects.  Color components are from 0.0 to 1.0.  Every pixel drawn will be multiplied (i.e. tinted) by this color.  This is a global setting, so it will affect all subsequent drawing operations.",
           key = "lovr.graphics.setColor",
           module = "lovr.graphics",
-          notes = "The default color is `(1, 1, 1, 1)`.",
+          notes = "The default color is `(1.0, 1.0, 1.0, 1.0)`.",
           variants = {
             {
               arguments = {
@@ -9285,7 +9223,7 @@ return {
                 {
                   name = "font",
                   type = "Font",
-                  description = "The font to use.  If `nil`, the default font is set.",
+                  description = "The font to use.  If `nil`, the default font is used (Varela Round).",
                   default = "nil"
                 }
               },
@@ -9858,17 +9796,20 @@ return {
                 {
                   name = "x",
                   type = "number",
-                  description = "The amount to translate on the x axis."
+                  description = "The amount to translate on the x axis.",
+                  default = "0"
                 },
                 {
                   name = "y",
                   type = "number",
-                  description = "The amount to translate on the y axis."
+                  description = "The amount to translate on the y axis.",
+                  default = "0"
                 },
                 {
                   name = "z",
                   type = "number",
-                  description = "The amount to translate on the z axis."
+                  description = "The amount to translate on the z axis.",
+                  default = "0"
                 }
               },
               returns = {}
@@ -14395,68 +14336,6 @@ return {
             }
           }
         },
-        {
-          name = "orientationToDirection",
-          summary = "Convert an angle/axis orientation to a direction vector.",
-          description = "Converts a rotation in angle/axis representation into a direction vector.",
-          key = "lovr.math.orientationToDirection",
-          module = "lovr.math",
-          related = {
-            "lovr.math.lookAt"
-          },
-          examples = {
-            {
-              description = "Give Controllers laser beams.",
-              code = "function lovr.draw()\n  for i, controller in ipairs(lovr.headset.getControllers()) do\n    local x, y, z = controller:getPosition()\n    local angle, ax, ay, az = controller:getOrientation()\n    local dx, dy, dz = lovr.math.orientationToDirection(angle, ax, ay, az)\n    local length = 2\n    lovr.graphics.line(x, y, z, x + dx * length, y + dy * length, z + dz * length)\n  end\nend"
-            }
-          },
-          variants = {
-            {
-              arguments = {
-                {
-                  name = "angle",
-                  type = "number",
-                  description = "The angle (in radians)."
-                },
-                {
-                  name = "ax",
-                  type = "number",
-                  description = "The x component of the axis of rotation.",
-                  default = "0"
-                },
-                {
-                  name = "ay",
-                  type = "number",
-                  description = "The y component of the axis of rotation.",
-                  default = "1"
-                },
-                {
-                  name = "az",
-                  type = "number",
-                  description = "The z component of the axis of rotation.",
-                  default = "0"
-                }
-              },
-              returns = {
-                {
-                  name = "x",
-                  type = "number",
-                  description = "The x component of the direction vector."
-                },
-                {
-                  name = "y",
-                  type = "number",
-                  description = "The y component of the direction vector."
-                },
-                {
-                  name = "z",
-                  type = "number",
-                  description = "The z component of the direction vector."
-                }
-              }
-            }
-          }
-        },
         {
           name = "quat",
           summary = "Create a new quat.",

+ 64 - 36
api/lovr/graphics/createWindow.lua

@@ -4,45 +4,73 @@ return {
   description = 'Create the desktop window, usually used to mirror the headset display.',
   arguments = {
     {
-      name = 'width',
-      type = 'number',
-      default = '1080',
-      description = 'The width of the window.'
-    },
-    {
-      name = 'height',
-      type = 'number',
-      default = '600',
-      description = 'The height of the window.'
-    },
-    {
-      name = 'fullscreen',
-      type = 'boolean',
-      default = 'false',
-      description = 'Whether the window should be fullscreen.'
-    },
-    {
-      name = 'msaa',
-      type = 'number',
-      default = '0',
-      description = 'The number of samples to use for multisample antialiasing.'
-    },
-    {
-      name = 'title',
-      type = 'string',
-      default = 'nil',
-      description = 'The window title.'
-    },
-    {
-      name = 'icon',
-      type = 'string',
-      default = 'nil',
-      description = 'A path to an image to use for the window icon.'
+      name = 'flags',
+      type = 'table',
+      description = 'Flags to customize the window\'s appearance and behavior.',
+      table = {
+        {
+          name = 'width',
+          type = 'number',
+          default = '1080',
+          description = 'The width of the window, or 0 to use the size of the monitor.'
+        },
+        {
+          name = 'height',
+          type = 'number',
+          default = '600',
+          description = 'The height of the window, or 0 to use the size of the monitor.'
+        },
+        {
+          name = 'fullscreen',
+          type = 'boolean',
+          default = 'false',
+          description = 'Whether the window should be fullscreen.'
+        },
+        {
+          name = 'resizable',
+          type = 'boolean',
+          default = 'false',
+          description = 'Whether the window should be resizable.'
+        },
+        {
+          name = 'msaa',
+          type = 'number',
+          default = '0',
+          description = 'The number of samples to use for multisample antialiasing.'
+        },
+        {
+          name = 'title',
+          type = 'string',
+          default = 'LÖVR',
+          description = 'The window title.'
+        },
+        {
+          name = 'icon',
+          type = 'string',
+          default = 'nil',
+          description = 'A path to an image to use for the window icon.'
+        },
+        {
+          name = 'vsync',
+          type = 'number',
+          default = '0',
+          description = [[
+            0 to disable vsync, 1 to enable.  This is only a hint, and may not be respected if
+            necessary for the current VR display.
+          ]]
+        }
+      }
     }
   },
   returns = {},
   notes = [[
-    This function can only be called once. It is normally called internally, but you can override
+    This function can only be called once.  It is normally called internally, but you can override
     this by setting window to `nil` in conf.lua.  See `lovr.conf` for more information.
-  ]]
+
+    The window must be created before any `lovr.graphics` functions can be used.
+  ]],
+  related = {
+    'lovr.graphics.hasWindow',
+    'lovr.conf'
+  }
 }

+ 2 - 11
api/lovr/graphics/fill.lua

@@ -7,10 +7,6 @@ return {
       type = 'Texture',
       description = 'The texture to use.'
     },
-    canvas = {
-      type = 'Canvas',
-      description = 'The first Texture attached to this Canvas will be used.'
-    },
     u = {
       type = 'number',
       default = '0',
@@ -35,15 +31,10 @@ return {
   returns = {},
   variants = {
     {
-      description = 'Fills the screen with a Texture.',
+      description = 'Fills the screen with a region of a Texture.',
       arguments = { 'texture', 'u', 'v', 'w', 'h' },
       returns = {}
     },
-    {
-      description = 'Fills the screen with the first Texture attached to a Canvas.',
-      arguments = { 'canvas', 'u', 'v', 'w', 'h' },
-      returns = {}
-    },
     {
       description = 'Fills the screen with the active color.',
       arguments = {},
@@ -52,6 +43,6 @@ return {
   },
   notes = [[
     This function ignores stereo rendering, so it will stretch the input across the entire Canvas if
-    it's stereo.
+    it's stereo.  Special shaders are currently required for correct stereo fills.
   ]]
 }

+ 2 - 2
api/lovr/graphics/getAlphaSampling.lua

@@ -1,6 +1,6 @@
 return {
   tag = 'graphicsState',
-  summary = 'Get whether alpha sampling (alpha to coverage) is enabled.',
+  summary = 'Get whether alpha sampling is enabled.',
   description = [[
     Returns whether or not alpha sampling is enabled.  Alpha sampling is also known as
     alpha-to-coverage.  When it is enabled, the alpha channel of a pixel is factored into how
@@ -16,7 +16,7 @@ return {
   },
   notes = [[
     - Alpha sampling is disabled by default.
-    - This feature can be used for a cheap transparency effect, pixels with an alpha of zero will
+    - This feature can be used for a simple transparency effect, pixels with an alpha of zero will
       have their depth value discarded, allowing things behind them to show through (normally you
       have to sort objects or write a shader for this).
   ]]

+ 1 - 1
api/lovr/graphics/getBackgroundColor.lua

@@ -27,5 +27,5 @@ return {
       description = 'The alpha component of the background color.'
     }
   },
-  notes = 'The default background color is black.'
+  notes = 'The default background color is `(0.0, 0.0, 0.0, 1.0)`.'
 }

+ 1 - 1
api/lovr/graphics/getColor.lua

@@ -28,5 +28,5 @@ return {
       description = 'The alpha component of the color.'
     }
   },
-  notes = 'The default color is white.'
+  notes = 'The default color is `(1.0, 1.0, 1.0, 1.0)`.'
 }

+ 2 - 1
api/lovr/graphics/getDimensions.lua

@@ -17,6 +17,7 @@ return {
   },
   related = {
     'lovr.graphics.getWidth',
-    'lovr.graphics.getHeight'
+    'lovr.graphics.getHeight',
+    'lovr.graphics.getPixelDensity'
   }
 }

+ 2 - 1
api/lovr/graphics/getHeight.lua

@@ -12,6 +12,7 @@ return {
   },
   related = {
     'lovr.graphics.getWidth',
-    'lovr.graphics.getDimensions'
+    'lovr.graphics.getDimensions',
+    'lovr.graphics.getPixelDensity'
   }
 }

+ 2 - 1
api/lovr/graphics/getWidth.lua

@@ -12,6 +12,7 @@ return {
   },
   related = {
     'lovr.graphics.getHeight',
-    'lovr.graphics.getDimensions'
+    'lovr.graphics.getDimensions',
+    'lovr.graphics.getPixelDensity'
   }
 }

+ 1 - 0
api/lovr/graphics/hasWindow.lua

@@ -10,6 +10,7 @@ return {
       description = 'Whether a window is created.'
     }
   },
+  notes = 'Most of the `lovr.graphics` functionality will only work if a window is created.',
   related = {
     'lovr.graphics.createWindow',
     'lovr.conf'

+ 3 - 24
api/lovr/graphics/newModel.lua

@@ -7,22 +7,9 @@ return {
       type = 'string',
       description = 'The filename of the model to load.'
     },
-    texture = {
-      type = 'string',
-      default = 'nil',
-      description = 'The filename of the texture to apply to the model.'
-    },
-    material = {
-      type = 'Material',
-      default = 'nil',
-      description = [[
-        The material to apply to the model.  If nil, the materials will be loaded from
-        the model file.
-      ]]
-    },
     modelData = {
       type = 'ModelData',
-      description = 'The ModelData holding the data for the Model.'
+      description = 'The ModelData containing the data for the Model.'
     }
   },
   returns = {
@@ -33,19 +20,11 @@ return {
   },
   variants = {
     {
-      arguments = { 'filename', 'texture' },
-      returns = { 'model' }
-    },
-    {
-      arguments = { 'filename', 'material' },
-      returns = { 'model' }
-    },
-    {
-      arguments = { 'modelData', 'texture' },
+      arguments = { 'filename' },
       returns = { 'model' }
     },
     {
-      arguments = { 'modelData', 'material' },
+      arguments = { 'modelData' },
       returns = { 'model' }
     }
   },

+ 1 - 4
api/lovr/graphics/reset.lua

@@ -1,10 +1,7 @@
 return {
   tag = 'graphicsState',
   summary = 'Reset all graphics state.',
-  description = [[
-    Resets the graphics state.  This includes the coordinate transformation, projection, shader,
-    colors, scissor, and culling state.
-  ]],
+  description = 'Resets all graphics state to the initial values.',
   arguments = {},
   returns = {}
 }

+ 1 - 0
api/lovr/graphics/rotate.lua

@@ -10,6 +10,7 @@ return {
   arguments = {
     {
       name = 'angle',
+      default = '0',
       type = 'number',
       description = 'The amount to rotate the coordinate system by, in radians.'
     },

+ 1 - 0
api/lovr/graphics/scale.lua

@@ -12,6 +12,7 @@ return {
     {
       name = 'x',
       type = 'number',
+      default = '1.0',
       description = 'The amount to scale on the x axis.'
     },
     {

+ 1 - 1
api/lovr/graphics/setAlphaSampling.lua

@@ -16,7 +16,7 @@ return {
   returns = {},
   notes = [[
     - Alpha sampling is disabled by default.
-    - This feature can be used for a cheap transparency effect, pixels with an alpha of zero will
+    - This feature can be used for a simple transparency effect, pixels with an alpha of zero will
       have their depth value discarded, allowing things behind them to show through (normally you
       have to sort objects or write a shader for this).
   ]]

+ 1 - 1
api/lovr/graphics/setBackgroundColor.lua

@@ -46,5 +46,5 @@ return {
       returns = {}
     }
   },
-  notes = 'The default background color is `(0, 0, 0, 1)`.'
+  notes = 'The default background color is `(0.0, 0.0, 0.0, 1.0)`.'
 }

+ 1 - 1
api/lovr/graphics/setColor.lua

@@ -48,7 +48,7 @@ return {
       returns = {}
     }
   },
-  notes = 'The default color is `(1, 1, 1, 1)`.',
+  notes = 'The default color is `(1.0, 1.0, 1.0, 1.0)`.',
   example = {
     description = 'Draw a red cube.',
     code = [[

+ 1 - 1
api/lovr/graphics/setFont.lua

@@ -7,7 +7,7 @@ return {
       name = 'font',
       type = 'Font',
       default = 'nil',
-      description = 'The font to use.  If `nil`, the default font is set.'
+      description = 'The font to use.  If `nil`, the default font is used (Varela Round).'
     }
   },
   returns = {},

+ 3 - 0
api/lovr/graphics/translate.lua

@@ -12,16 +12,19 @@ return {
     {
       name = 'x',
       type = 'number',
+      default = '0',
       description = 'The amount to translate on the x axis.'
     },
     {
       name = 'y',
       type = 'number',
+      default = '0',
       description = 'The amount to translate on the y axis.'
     },
     {
       name = 'z',
       type = 'number',
+      default = '0',
       description = 'The amount to translate on the z axis.'
     }
   },

+ 0 - 63
api/lovr/math/orientationToDirection.lua

@@ -1,63 +0,0 @@
-return {
-  summary = 'Convert an angle/axis orientation to a direction vector.',
-  description = 'Converts a rotation in angle/axis representation into a direction vector.',
-  arguments = {
-    {
-      name = 'angle',
-      type = 'number',
-      description = 'The angle (in radians).'
-    },
-    {
-      name = 'ax',
-      type = 'number',
-      default = '0',
-      description = 'The x component of the axis of rotation.'
-    },
-    {
-      name = 'ay',
-      type = 'number',
-      default = '1',
-      description = 'The y component of the axis of rotation.'
-    },
-    {
-      name = 'az',
-      type = 'number',
-      default = '0',
-      description = 'The z component of the axis of rotation.'
-    }
-  },
-  returns = {
-    {
-      name = 'x',
-      type = 'number',
-      description = 'The x component of the direction vector.'
-    },
-    {
-      name = 'y',
-      type = 'number',
-      description = 'The y component of the direction vector.'
-    },
-    {
-      name = 'z',
-      type = 'number',
-      description = 'The z component of the direction vector.'
-    }
-  },
-  example = {
-    description = 'Give Controllers laser beams.',
-    code = [[
-      function lovr.draw()
-        for i, controller in ipairs(lovr.headset.getControllers()) do
-          local x, y, z = controller:getPosition()
-          local angle, ax, ay, az = controller:getOrientation()
-          local dx, dy, dz = lovr.math.orientationToDirection(angle, ax, ay, az)
-          local length = 2
-          lovr.graphics.line(x, y, z, x + dx * length, y + dy * length, z + dz * length)
-        end
-      end
-    ]]
-  },
-  related = {
-    'lovr.math.lookAt'
-  }
-}

+ 9 - 15
guides/Callbacks_and_Modules.md

@@ -38,12 +38,12 @@ function lovr.update(dt)
   print('updating', dt)
 end
 
-function lovr.draw(eye)
-  -- This is called twice every frame (once for each eye).
+function lovr.draw()
+  -- This is called once every frame.
   --
   -- You can use it to render the scene.
 
-  print('rendering the ' .. eye .. ' eye')
+  print('rendering')
 end
 ```
 
@@ -101,8 +101,8 @@ You've already seen `lovr.graphics.print`, but here's another example:
 
 ```
 function lovr.load()
-  -- Load a model with a texture
-  model = lovr.graphics.newModel('monkey.obj', 'monkey.png')
+  -- Load a 3D model
+  model = lovr.graphics.newModel('monkey.obj')
 end
 
 function lovr.draw()
@@ -133,17 +133,11 @@ HMD, you can call `lovr.headset.getPosition` which returns 3 numbers correspondi
 position in 3D space.  You can also call `lovr.headset.getOrientation` which returns four numbers
 representing a rotation in angle/axis format.
 
-The `lovr.headset.getControllers` function returns a list of all connected controllers.  You can
-query pose info for controllers using `Controller:getPosition` and `Controller:getOrientation`,
-similar to the HMD.  There are also `Controller:getAxis` and `Controller:isDown` functions for
-determining input state.
-
-Several callbacks are relevant to the headset module.  The `lovr.controlleradded` callback is run
-whenever a new controller is connected, and there is a similar `controllerremoved` callback.  Also,
-there is the `lovr.controllerpressed` callback for when a button on a controller is pressed, with
-a similar callback for `controllerreleased`.
+You can also pass the name of a hand to these functions to get the pose of a hand: `hand/left` or
+`hand/right`.  The `lovr.headset.isDown(hand, button)` and `lovr.headset.getAxis(hand, axis)`
+functions can be used to figure out the state of buttons and other controls on the controllers.
 
-Here's an example that draws a sphere in the "opposite" position of the headset:
+Here's a simple example that draws a sphere in the "opposite" position of the headset:
 
 ```
 function lovr.draw()