Browse Source

Document uvwh plane arguments;

bjorn 6 years ago
parent
commit
78005dcce1
2 changed files with 68 additions and 3 deletions
  1. 39 0
      api/init.lua
  2. 29 3
      api/lovr/graphics/plane.lua

+ 39 - 0
api/init.lua

@@ -8170,6 +8170,7 @@ return {
           description = "Draws a plane with a given position, size, and orientation.",
           key = "lovr.graphics.plane",
           module = "lovr.graphics",
+          notes = "The `u`, `v`, `w`, `h` arguments can be used to select a subregion of the diffuse texture to apply to the plane.  One efficient technique for rendering many planes with different textures is to pack all of the textures into a single image, and then use the uv arguments to select a sub-rectangle to use for each plane.",
           variants = {
             {
               arguments = {
@@ -8231,6 +8232,25 @@ return {
                   type = "number",
                   description = "The z component of the rotation axis.",
                   default = "0"
+                },
+                {
+                  name = "u",
+                  type = "number",
+                  description = "The u coordinate of the diffuse texture.",
+                  default = "0.0"
+                },
+                {
+                  name = "v",
+                  type = "number",
+                  description = "The width of the diffuse texture to render.",
+                  default = "1.0"
+                },
+                nil,
+                {
+                  name = "h",
+                  type = "number",
+                  description = "The height of the diffuse texture to render.",
+                  default = "1.0"
                 }
               },
               returns = {}
@@ -8296,6 +8316,25 @@ return {
                   type = "number",
                   description = "The z component of the rotation axis.",
                   default = "0"
+                },
+                {
+                  name = "u",
+                  type = "number",
+                  description = "The u coordinate of the diffuse texture.",
+                  default = "0.0"
+                },
+                {
+                  name = "v",
+                  type = "number",
+                  description = "The width of the diffuse texture to render.",
+                  default = "1.0"
+                },
+                nil,
+                {
+                  name = "h",
+                  type = "number",
+                  description = "The height of the diffuse texture to render.",
+                  default = "1.0"
                 }
               },
               returns = {}

+ 29 - 3
api/lovr/graphics/plane.lua

@@ -56,18 +56,44 @@ return {
       type = 'number',
       default = '0',
       description = 'The z component of the rotation axis.'
+    },
+    u = {
+      type = 'number',
+      default = '0.0',
+      description = 'The u coordinate of the diffuse texture.'
+    },
+    v = {
+      type = 'number',
+      default = '0.0',
+      description = 'The v coordinate of the diffuse texture.'
+    },
+    v = {
+      type = 'number',
+      default = '1.0',
+      description = 'The width of the diffuse texture to render.'
+    },
+    h = {
+      type = 'number',
+      default = '1.0',
+      description = 'The height of the diffuse texture to render.'
     }
   },
   returns = {},
   variants = {
     {
-      arguments = { 'mode', 'x', 'y', 'z', 'width', 'height', 'angle', 'ax', 'ay', 'az' },
+      arguments = { 'mode', 'x', 'y', 'z', 'width', 'height', 'angle', 'ax', 'ay', 'az', 'u', 'v', 'w', 'h' },
       returns = {}
     },
     {
       description = 'Draw a plane with a custom material.',
-      arguments = { 'material', 'x', 'y', 'z', 'width', 'height', 'angle', 'ax', 'ay', 'az' },
+      arguments = { 'material', 'x', 'y', 'z', 'width', 'height', 'angle', 'ax', 'ay', 'az', 'u', 'v', 'w', 'h' },
       returns = {}
     }
-  }
+  },
+  notes = [[
+    The `u`, `v`, `w`, `h` arguments can be used to select a subregion of the diffuse texture to
+    apply to the plane.  One efficient technique for rendering many planes with different textures
+    is to pack all of the textures into a single image, and then use the uv arguments to select
+    a sub-rectangle to use for each plane.
+  ]]
 }