Browse Source

push/pop/origin;

bjorn 3 years ago
parent
commit
83e8c15670
4 changed files with 116 additions and 0 deletions
  1. 70 0
      api/init.lua
  2. 12 0
      api/lovr/graphics/origin.lua
  3. 17 0
      api/lovr/graphics/pop.lua
  4. 17 0
      api/lovr/graphics/push.lua

+ 70 - 0
api/init.lua

@@ -5067,6 +5067,51 @@ return {
             }
           }
         },
+        {
+          name = "origin",
+          summary = "Reset the transform to the origin.",
+          description = "Resets the transform to the origin.  This is called automatically at the beginning of each render pass.",
+          key = "lovr.graphics.origin",
+          module = "lovr.graphics",
+          notes = "At the beginning of a render pass or a batch pass, the transform will be at the origin, as though this function was just called.",
+          variants = {
+            {
+              arguments = {},
+              returns = {}
+            }
+          },
+          related = {
+            "lovr.graphics.translate",
+            "lovr.graphics.rotate",
+            "lovr.graphics.scale",
+            "lovr.graphics.transform"
+          }
+        },
+        {
+          name = "pop",
+          summary = "Restore original state from a stack.",
+          description = "Restores the original state from one of the stacks.",
+          key = "lovr.graphics.pop",
+          module = "lovr.graphics",
+          notes = "Currently, 16 levels of nesting are supported for the transform stack and 4 levels of nesting are supported for the pipeline stack.",
+          variants = {
+            {
+              arguments = {
+                {
+                  name = "stack",
+                  type = "StackType",
+                  description = "The type of stack to pop.",
+                  default = "'transform'"
+                }
+              },
+              returns = {}
+            }
+          },
+          related = {
+            "lovr.graphics.push",
+            "StackType"
+          }
+        },
         {
           name = "prepare",
           summary = "Start recording graphics work.",
@@ -5083,6 +5128,31 @@ return {
             }
           }
         },
+        {
+          name = "push",
+          summary = "Push state onto a stack.",
+          description = "Pushes a copy of the current state onto a stack.  Further modifications to the state will operate on the copy, and the original state can be restored using `lovr.graphics.pop`.  Every push operation must be followed by a corresponding pop to keep the stack balanced.  The calls can be nested to create hierarchies of nested state.\n\nThe types of state that can be saved and restored in this way are given by `StackType`. Currently, the `transform` stack can be used to save coordinate spaces, the `pipeline` stack can be used to save pipeline states, and the `label` stack can be used to create named scopes for graphics debugging tools.",
+          key = "lovr.graphics.push",
+          module = "lovr.graphics",
+          notes = "Currently, 16 levels of nesting are supported for the transform stack and 4 levels of nesting are supported for the pipeline stack.",
+          variants = {
+            {
+              arguments = {
+                {
+                  name = "stack",
+                  type = "StackType",
+                  description = "The type of stack to push.",
+                  default = "'transform'"
+                }
+              },
+              returns = {}
+            }
+          },
+          related = {
+            "lovr.graphics.pop",
+            "StackType"
+          }
+        },
         {
           name = "submit",
           summary = "Submit recorded graphics work to the GPU.",

+ 12 - 0
api/lovr/graphics/origin.lua

@@ -0,0 +1,12 @@
+return {
+  summary = 'Reset the transform to the origin.',
+  description = 'TODO',
+  arguments = {},
+  returns = {},
+  related = {
+    'lovr.graphics.translate',
+    'lovr.graphics.rotate',
+    'lovr.graphics.scale',
+    'lovr.graphics.transform'
+  }
+}

+ 17 - 0
api/lovr/graphics/pop.lua

@@ -0,0 +1,17 @@
+return {
+  summary = 'Restore original state from a stack.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'stack',
+      type = 'StackType',
+      default = [['transform']],
+      description = 'The type of stack to pop.'
+    }
+  },
+  returns = {},
+  related = {
+    'lovr.graphics.push',
+    'StackType'
+  }
+}

+ 17 - 0
api/lovr/graphics/push.lua

@@ -0,0 +1,17 @@
+return {
+  summary = 'Push state onto a stack.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'stack',
+      type = 'StackType',
+      default = [['transform']],
+      description = 'The type of stack to push.'
+    }
+  },
+  returns = {},
+  related = {
+    'lovr.graphics.pop',
+    'StackType'
+  }
+}