Browse Source

Pass:getViewport/Scissor;

bjorn 1 year ago
parent
commit
f1819277d5

+ 107 - 2
api/init.lua

@@ -17838,6 +17838,46 @@ return {
                 }
               }
             },
+            {
+              name = "getScissor",
+              tag = "camera",
+              summary = "Get the scissor rectangle.",
+              description = "Returns the scissor rectangle, or `nil` if no scissor is set.  Any pixels outside the scissor rectangle will not be drawn.",
+              key = "Pass:getScissor",
+              module = "lovr.graphics",
+              notes = "The scissor will apply to all draws in a Pass when the pass is submitted.\n\nThe default scissor rectangle covers the entire dimensions of the render pass textures.",
+              related = {
+                "Pass:getViewport",
+                "Pass:setViewport"
+              },
+              variants = {
+                {
+                  arguments = {},
+                  returns = {
+                    {
+                      name = "x",
+                      type = "number",
+                      description = "The x coordinate of the upper-left corner of the scissor rectangle."
+                    },
+                    {
+                      name = "y",
+                      type = "number",
+                      description = "The y coordinate of the upper-left corner of the scissor rectangle."
+                    },
+                    {
+                      name = "w",
+                      type = "number",
+                      description = "The width of the scissor rectangle."
+                    },
+                    {
+                      name = "h",
+                      type = "number",
+                      description = "The height of the scissor rectangle."
+                    }
+                  }
+                }
+              }
+            },
             {
               name = "getTarget",
               tag = "pass-misc",
@@ -17997,6 +18037,59 @@ return {
                 }
               }
             },
+            {
+              name = "getViewport",
+              tag = "camera",
+              summary = "Get the viewport.",
+              description = "Returns the viewport, or `nil` if no viewport is set.  Everything rendered will get mapped to the rectangle defined by the viewport.  More specifically, this defines the transformation from normalized device coordinates to pixel coordinates.",
+              key = "Pass:getViewport",
+              module = "lovr.graphics",
+              notes = "The viewport will apply to all draws in a Pass when the pass is submitted.\n\nThe viewport rectangle can use floating point numbers.\n\nA negative viewport height (with a y coordinate equal to the bottom of the viewport) can be used to flip the rendering vertically.\n\nThe default viewport extends from `(0, 0)` to the dimensions of the target textures, with min depth and max depth respectively set to 0 and 1.",
+              related = {
+                "Pass:getScissor",
+                "Pass:setScissor",
+                "Pass:getDimensions"
+              },
+              variants = {
+                {
+                  arguments = {},
+                  returns = {
+                    {
+                      name = "x",
+                      type = "number",
+                      description = "The x coordinate of the upper-left corner of the viewport."
+                    },
+                    {
+                      name = "y",
+                      type = "number",
+                      description = "The y coordinate of the upper-left corner of the viewport."
+                    },
+                    {
+                      name = "w",
+                      type = "number",
+                      description = "The width of the viewport."
+                    },
+                    {
+                      name = "h",
+                      type = "number",
+                      description = "The height of the viewport.  May be negative."
+                    },
+                    {
+                      name = "dmin",
+                      type = "number",
+                      description = "The min component of the depth range.",
+                      default = "0.0"
+                    },
+                    {
+                      name = "dmax",
+                      type = "number",
+                      description = "The max component of the depth range.",
+                      default = "1.0"
+                    }
+                  }
+                }
+              }
+            },
             {
               name = "getWidth",
               tag = "pass-misc",
@@ -19920,8 +20013,9 @@ return {
               description = "Sets the scissor rectangle.  Any pixels outside the scissor rectangle will not be drawn.",
               key = "Pass:setScissor",
               module = "lovr.graphics",
-              notes = "The scissor will apply to all draws in a Pass, even if this function is called after adding the draws.\n\n`x` and `y` can not be negative.\n\nThe default scissor rectangle covers the entire dimensions of the render pass textures.",
+              notes = "The scissor will apply to all draws in a Pass when the pass is submitted, even if this function is called after adding the draws.\n\n`x` and `y` can not be negative.  `w` and `h` must be positive.\n\nBy default, the scissor is disabled and will cover the entire render area.",
               related = {
+                "Pass:getViewport",
                 "Pass:setViewport"
               },
               variants = {
@@ -19949,6 +20043,11 @@ return {
                     }
                   },
                   returns = {}
+                },
+                {
+                  description = "Disable the scissor.",
+                  arguments = {},
+                  returns = {}
                 }
               }
             },
@@ -20237,8 +20336,9 @@ return {
               description = "Sets the viewport.  Everything rendered will get mapped to the rectangle defined by the viewport.  More specifically, this defines the transformation from normalized device coordinates to pixel coordinates.",
               key = "Pass:setViewport",
               module = "lovr.graphics",
-              notes = "The viewport will apply to all draws in a Pass, even if this function is called after adding the draws.\n\nThe viewport rectangle can use floating point numbers.\n\nA negative viewport height (with a y coordinate equal to the bottom of the viewport) can be used to flip the rendering vertically.\n\nThe default viewport extends from `(0, 0)` to the dimensions of the target textures, with min depth and max depth respectively set to 0 and 1.",
+              notes = "The viewport will apply to all draws in a Pass when the pass is submitted, even if this function is called after adding the draws.\n\nThe viewport rectangle can use floating point numbers.\n\nA negative viewport height (with a y coordinate equal to the bottom of the viewport) can be used to flip the rendering vertically.\n\nThe default viewport extends from `(0, 0)` to the dimensions of the target textures, with min depth and max depth respectively set to 0 and 1.",
               related = {
+                "Pass:getScissor",
                 "Pass:setScissor",
                 "Pass:getDimensions"
               },
@@ -20279,6 +20379,11 @@ return {
                     }
                   },
                   returns = {}
+                },
+                {
+                  description = "Disable the viewport.",
+                  arguments = {},
+                  returns = {}
                 }
               }
             },

+ 42 - 0
api/lovr/graphics/Pass/getScissor.lua

@@ -0,0 +1,42 @@
+return {
+  tag = 'camera',
+  summary = 'Get the scissor rectangle.',
+  description = [[
+    Returns the scissor rectangle, or `nil` if no scissor is set.  Any pixels outside the scissor
+    rectangle will not be drawn.
+  ]],
+  arguments = {},
+  returns = {
+    x = {
+      type = 'number',
+      description = 'The x coordinate of the upper-left corner of the scissor rectangle.',
+    },
+    y = {
+      type = 'number',
+      description = 'The y coordinate of the upper-left corner of the scissor rectangle.',
+    },
+    w = {
+      type = 'number',
+      description = 'The width of the scissor rectangle.',
+    },
+    h = {
+      type = 'number',
+      description = 'The height of the scissor rectangle.',
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'x', 'y', 'w', 'h' }
+    }
+  },
+  notes = [[
+    The scissor will apply to all draws in a Pass when the pass is submitted.
+
+    The default scissor rectangle covers the entire dimensions of the render pass textures.
+  ]],
+  related = {
+    'Pass:getViewport',
+    'Pass:setViewport'
+  }
+}

+ 60 - 0
api/lovr/graphics/Pass/getViewport.lua

@@ -0,0 +1,60 @@
+return {
+  tag = 'camera',
+  summary = 'Get the viewport.',
+  description = [[
+    Returns the viewport, or `nil` if no viewport is set.  Everything rendered will get mapped to
+    the rectangle defined by the viewport.  More specifically, this defines the transformation from
+    normalized device coordinates to pixel coordinates.
+  ]],
+  arguments = {},
+  returns = {
+    x = {
+      type = 'number',
+      description = 'The x coordinate of the upper-left corner of the viewport.',
+    },
+    y = {
+      type = 'number',
+      description = 'The y coordinate of the upper-left corner of the viewport.',
+    },
+    w = {
+      type = 'number',
+      description = 'The width of the viewport.',
+    },
+    h = {
+      type = 'number',
+      description = 'The height of the viewport.  May be negative.',
+    },
+    dmin = {
+      type = 'number',
+      default = '0.0',
+      description = 'The min component of the depth range.'
+    },
+    dmax = {
+      type = 'number',
+      default = '1.0',
+      description = 'The max component of the depth range.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'x', 'y', 'w', 'h', 'dmin', 'dmax' }
+    }
+  },
+  notes = [[
+    The viewport will apply to all draws in a Pass when the pass is submitted.
+
+    The viewport rectangle can use floating point numbers.
+
+    A negative viewport height (with a y coordinate equal to the bottom of the viewport) can be used
+    to flip the rendering vertically.
+
+    The default viewport extends from `(0, 0)` to the dimensions of the target textures, with min
+    depth and max depth respectively set to 0 and 1.
+  ]],
+  related = {
+    'Pass:getScissor',
+    'Pass:setScissor',
+    'Pass:getDimensions'
+  }
+}

+ 10 - 4
api/lovr/graphics/Pass/setScissor.lua

@@ -27,17 +27,23 @@ return {
     {
       arguments = { 'x', 'y', 'w', 'h' },
       returns = {}
+    },
+    {
+      description = 'Disable the scissor.',
+      arguments = {},
+      returns = {}
     }
   },
   notes = [[
-    The scissor will apply to all draws in a Pass, even if this function is called after adding the
-    draws.
+    The scissor will apply to all draws in a Pass when the pass is submitted, even if this function
+    is called after adding the draws.
 
-    `x` and `y` can not be negative.
+    `x` and `y` can not be negative.  `w` and `h` must be positive.
 
-    The default scissor rectangle covers the entire dimensions of the render pass textures.
+    By default, the scissor is disabled and will cover the entire render area.
   ]],
   related = {
+    'Pass:getViewport',
     'Pass:setViewport'
   }
 }

+ 8 - 2
api/lovr/graphics/Pass/setViewport.lua

@@ -39,11 +39,16 @@ return {
     {
       arguments = { 'x', 'y', 'w', 'h', 'dmin', 'dmax' },
       returns = {}
+    },
+    {
+      description = 'Disable the viewport.',
+      arguments = {},
+      returns = {}
     }
   },
   notes = [[
-    The viewport will apply to all draws in a Pass, even if this function is called after adding the
-    draws.
+    The viewport will apply to all draws in a Pass when the pass is submitted, even if this function
+    is called after adding the draws.
 
     The viewport rectangle can use floating point numbers.
 
@@ -54,6 +59,7 @@ return {
     depth and max depth respectively set to 0 and 1.
   ]],
   related = {
+    'Pass:getScissor',
     'Pass:setScissor',
     'Pass:getDimensions'
   }