Browse Source

DrawMode updates;

bjorn 1 year ago
parent
commit
63a5d331a9

+ 73 - 29
api/init.lua

@@ -3196,10 +3196,10 @@ return {
           }
         },
         {
-          name = "DrawMode",
+          name = "ModelDrawMode",
           summary = "Different draw modes for meshes in ModelDatas.",
           description = "The DrawMode of a mesh determines how its vertices are connected together.",
-          key = "DrawMode",
+          key = "ModelDrawMode",
           module = "lovr.data",
           related = {
             "ModelData:getMeshDrawMode"
@@ -5831,7 +5831,7 @@ return {
                   returns = {
                     {
                       name = "mode",
-                      type = "DrawMode",
+                      type = "ModelDrawMode",
                       description = "The draw mode of the mesh."
                     }
                   }
@@ -9666,6 +9666,27 @@ return {
             }
           }
         },
+        {
+          name = "DrawMode",
+          summary = "Different ways to draw mesh vertices.",
+          description = "Different ways vertices in a mesh can be connected together and filled in with pixels.",
+          key = "DrawMode",
+          module = "lovr.graphics",
+          values = {
+            {
+              name = "points",
+              description = "Each vertex is rendered as a single point.  The size of the point can be controlled using the `pointSize` shader flag, or by writing to the `PointSize` variable in shaders.  The maximum point size is given by the `pointSize` limit from `lovr.graphics.getLimits`."
+            },
+            {
+              name = "lines",
+              description = "Pairs of vertices are connected with line segments.  To draw a single line through all of the vertices, an index buffer can be used to repeat vertices.  It is not currently possible to change the width of the lines, although cylinders or capsules can be used as an alternative."
+            },
+            {
+              name = "triangles",
+              description = "Every 3 vertices form a triangle, which is filled in with pixels (unless `Pass:setWireframe` is used).  This mode is the most commonly used."
+            }
+          }
+        },
         {
           name = "DrawStyle",
           summary = "Different styles to draw shapes.",
@@ -9889,27 +9910,6 @@ return {
             }
           }
         },
-        {
-          name = "MeshMode",
-          summary = "Different ways to draw mesh vertices.",
-          description = "Different ways vertices in a mesh can be connected together and filled in with pixels.",
-          key = "MeshMode",
-          module = "lovr.graphics",
-          values = {
-            {
-              name = "points",
-              description = "Each vertex is rendered as a single point.  The size of the point can be controlled using the `pointSize` shader flag, or by writing to the `PointSize` variable in shaders.  The maximum point size is given by the `pointSize` limit from `lovr.graphics.getLimits`."
-            },
-            {
-              name = "lines",
-              description = "Pairs of vertices are connected with line segments.  To draw a single line through all of the vertices, an index buffer can be used to repeat vertices.  It is not currently possible to change the width of the lines, although cylinders or capsules can be used as an alternative."
-            },
-            {
-              name = "triangles",
-              description = "Every 3 vertices form a triangle, which is filled in with pixels (unless `Pass:setWireframe` is used).  This mode is the most commonly used."
-            }
-          }
-        },
         {
           name = "OriginType",
           summary = "Different coordinate spaces for nodes in a Model.",
@@ -13140,6 +13140,28 @@ return {
             "lovr.graphics.newBuffer"
           },
           methods = {
+            {
+              name = "getDrawMode",
+              summary = "Get the draw mode of the Mesh.",
+              description = "Returns the `DrawMode` of the mesh, which controls how the vertices in the Mesh are connected together to create pixels.  The default is `triangles`.",
+              key = "Mesh:getDrawMode",
+              module = "lovr.graphics",
+              related = {
+                "Pass:setMeshMode"
+              },
+              variants = {
+                {
+                  arguments = {},
+                  returns = {
+                    {
+                      name = "mode",
+                      type = "DrawMode",
+                      description = "The current draw mode."
+                    }
+                  }
+                }
+              }
+            },
             {
               name = "getIndexBuffer",
               summary = "Get the Buffer backing the vertex indices of the Mesh.",
@@ -13317,6 +13339,28 @@ return {
                 }
               }
             },
+            {
+              name = "setDrawMode",
+              summary = "Set the draw mode of the Mesh.",
+              description = "Changes the `DrawMode` of the mesh, which controls how the vertices in the Mesh are connected together to create pixels.  The default is `triangles`.",
+              key = "Mesh:setDrawMode",
+              module = "lovr.graphics",
+              related = {
+                "Pass:setMeshMode"
+              },
+              variants = {
+                {
+                  arguments = {
+                    {
+                      name = "mode",
+                      type = "DrawMode",
+                      description = "The current draw mode."
+                    }
+                  },
+                  returns = {}
+                }
+              }
+            },
             {
               name = "setIndexBuffer",
               summary = "Set a Buffer for the Mesh to use for vertex indices.",
@@ -14195,7 +14239,7 @@ return {
                   returns = {
                     {
                       name = "mode",
-                      type = "MeshMode",
+                      type = "DrawMode",
                       description = "Whether the vertices are points, lines, or triangles."
                     },
                     {
@@ -14236,7 +14280,7 @@ return {
                   returns = {
                     {
                       name = "mode",
-                      type = "MeshMode",
+                      type = "DrawMode",
                       description = "Whether the vertices are points, lines, or triangles."
                     },
                     {
@@ -18123,7 +18167,7 @@ return {
               name = "line",
               tag = "drawing",
               summary = "Draw a line.",
-              description = "Draws a line between points.  `Pass:mesh` can also be used to draw line segments using the `line` `MeshMode`.",
+              description = "Draws a line between points.  `Pass:mesh` can also be used to draw line segments using the `line` `DrawMode`.",
               key = "Pass:line",
               module = "lovr.graphics",
               notes = "There is currently no way to increase line thickness.",
@@ -18212,7 +18256,7 @@ return {
                   code = "function lovr.draw(pass)\n  local vertices = {\n    vec3(  0,  .4, 0), vec4(1, 0, 0, 1),\n    vec3(-.5, -.4, 0), vec4(0, 1, 0, 1),\n    vec3( .5, -.4, 0), vec4(0, 0, 1, 1)\n  }\n\n  local format = {\n    { type = 'vec3', location = 'VertexPosition' },\n    { type = 'vec4', location = 'VertexColor' }\n  }\n\n  local triangle = lovr.graphics.getBuffer(vertices, format)\n\n  pass:mesh(triangle, 0, 1.7, -1)\nend"
                 }
               },
-              notes = "The index buffer defines the order the vertices are drawn in.  It can be used to reorder, reuse, or omit vertices from the mesh.\n\nWhen drawing without a vertex buffer, the `VertexIndex` variable can be used in shaders to compute the position of each vertex, possibly by reading data from other `Buffer` or `Texture` resources.\n\nThe active `MeshMode` controls whether the vertices are drawn as points, lines, or triangles.\n\nThe active `Material` is applied to the mesh.",
+              notes = "The index buffer defines the order the vertices are drawn in.  It can be used to reorder, reuse, or omit vertices from the mesh.\n\nWhen drawing without a vertex buffer, the `VertexIndex` variable can be used in shaders to compute the position of each vertex, possibly by reading data from other `Buffer` or `Texture` resources.\n\nThe active `DrawMode` controls whether the vertices are drawn as points, lines, or triangles.\n\nThe active `Material` is applied to the mesh.",
               variants = {
                 {
                   description = "Draw a range of vertices from a Buffer, using numbers for the transform.",
@@ -19887,7 +19931,7 @@ return {
                   arguments = {
                     {
                       name = "mode",
-                      type = "MeshMode",
+                      type = "DrawMode",
                       description = "The mesh mode to use."
                     }
                   },

+ 1 - 1
api/lovr/data/ModelData/getMeshDrawMode.lua

@@ -12,7 +12,7 @@ return {
   },
   returns = {
     mode = {
-      type = 'DrawMode',
+      type = 'ModelDrawMode',
       description = 'The draw mode of the mesh.'
     }
   },

+ 0 - 0
api/lovr/data/DrawMode.lua → api/lovr/data/ModelDrawMode.lua


+ 0 - 0
api/lovr/graphics/MeshMode.lua → api/lovr/graphics/DrawMode.lua


+ 23 - 0
api/lovr/graphics/Mesh/getDrawMode.lua

@@ -0,0 +1,23 @@
+return {
+  summary = 'Get the draw mode of the Mesh.',
+  description = [[
+    Returns the `DrawMode` of the mesh, which controls how the vertices in the Mesh are connected
+    together to create pixels.  The default is `triangles`.
+  ]],
+  arguments = {},
+  returns = {
+    mode = {
+      type = 'DrawMode',
+      description = 'The current draw mode.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'mode' }
+    }
+  },
+  related = {
+    'Pass:setMeshMode'
+  }
+}

+ 23 - 0
api/lovr/graphics/Mesh/setDrawMode.lua

@@ -0,0 +1,23 @@
+return {
+  summary = 'Set the draw mode of the Mesh.',
+  description = [[
+    Changes the `DrawMode` of the mesh, which controls how the vertices in the Mesh are connected
+    together to create pixels.  The default is `triangles`.
+  ]],
+  arguments = {
+    mode = {
+      type = 'DrawMode',
+      description = 'The current draw mode.'
+    }
+  },
+  returns = {},
+  variants = {
+    {
+      arguments = { 'mode' },
+      returns = {}
+    }
+  },
+  related = {
+    'Pass:setMeshMode'
+  }
+}

+ 1 - 1
api/lovr/graphics/Model/getNodeDraw.lua

@@ -19,7 +19,7 @@ return {
   },
   returns = {
     mode = {
-      type = 'MeshMode',
+      type = 'DrawMode',
       description = 'Whether the vertices are points, lines, or triangles.'
     },
     material = {

+ 1 - 1
api/lovr/graphics/Pass/line.lua

@@ -3,7 +3,7 @@ return {
   summary = 'Draw a line.',
   description = [[
     Draws a line between points.  `Pass:mesh` can also be used to draw line segments using the
-    `line` `MeshMode`.
+    `line` `DrawMode`.
   ]],
   arguments = {
     x1 = {

+ 1 - 1
api/lovr/graphics/Pass/mesh.lua

@@ -175,7 +175,7 @@ return {
     compute the position of each vertex, possibly by reading data from other `Buffer` or `Texture`
     resources.
 
-    The active `MeshMode` controls whether the vertices are drawn as points, lines, or triangles.
+    The active `DrawMode` controls whether the vertices are drawn as points, lines, or triangles.
 
     The active `Material` is applied to the mesh.
   ]],

+ 1 - 1
api/lovr/graphics/Pass/setMeshMode.lua

@@ -4,7 +4,7 @@ return {
   description = 'Changes the way vertices are connected together when drawing using `Pass:mesh`.',
   arguments = {
     mode = {
-      type = 'MeshMode',
+      type = 'DrawMode',
       description = 'The mesh mode to use.'
     }
   },