Bladeren bron

Texture:clear;

bjorn 1 jaar geleden
bovenliggende
commit
b7b2a0e4ea
2 gewijzigde bestanden met toevoegingen van 306 en 0 verwijderingen
  1. 205 0
      api/init.lua
  2. 101 0
      api/lovr/graphics/Texture/clear.lua

+ 205 - 0
api/init.lua

@@ -22728,6 +22728,211 @@ return {
             "Texture:newView"
           },
           methods = {
+            {
+              name = "clear",
+              summary = "Clear the Texture to a color.",
+              description = "Clears layers and mipmaps in a texture to a given color.\n\nWhen a Texture is being used as a canvas for a `Pass`, the clear color can be set with `Pass:setClear`, which a more efficient way to clear the texture before rendering.",
+              key = "Texture:clear",
+              module = "lovr.graphics",
+              notes = "The texture must have been created with the `transfer` usage to clear it.\n\nThe clear color will be interpreted as a linear color for sRGB formats.",
+              related = {
+                "Buffer:clear",
+                "Texture:setPixels",
+                "Pass:setClear"
+              },
+              variants = {
+                {
+                  description = "Clear the whole texture to zero (transparent black).",
+                  arguments = {},
+                  returns = {}
+                },
+                {
+                  arguments = {
+                    {
+                      name = "hex",
+                      type = "number",
+                      description = "The hexcode color to clear to."
+                    },
+                    {
+                      name = "layer",
+                      type = "number",
+                      description = "The index of the first layer to clear.",
+                      default = "1"
+                    },
+                    {
+                      name = "layerCount",
+                      type = "number",
+                      description = "The number of layers to clear.  If nil, clears the rest of the layers.",
+                      default = "nil"
+                    },
+                    {
+                      name = "mipmap",
+                      type = "number",
+                      description = "The index of the first mipmap to clear.",
+                      default = "1"
+                    },
+                    {
+                      name = "mipmapCount",
+                      type = "number",
+                      description = "The number of mipmaps to clear.  If nil, clears the rest of the mipmaps.",
+                      default = "nil"
+                    }
+                  },
+                  returns = {}
+                },
+                {
+                  arguments = {
+                    {
+                      name = "r",
+                      type = "number",
+                      description = "The red component of the clear color."
+                    },
+                    {
+                      name = "g",
+                      type = "number",
+                      description = "The green component of the clear color."
+                    },
+                    {
+                      name = "b",
+                      type = "number",
+                      description = "The blue component of the clear color."
+                    },
+                    {
+                      name = "a",
+                      type = "number",
+                      description = "The alpha component of the clear color."
+                    },
+                    {
+                      name = "layer",
+                      type = "number",
+                      description = "The index of the first layer to clear.",
+                      default = "1"
+                    },
+                    {
+                      name = "layerCount",
+                      type = "number",
+                      description = "The number of layers to clear.  If nil, clears the rest of the layers.",
+                      default = "nil"
+                    },
+                    {
+                      name = "mipmap",
+                      type = "number",
+                      description = "The index of the first mipmap to clear.",
+                      default = "1"
+                    },
+                    {
+                      name = "mipmapCount",
+                      type = "number",
+                      description = "The number of mipmaps to clear.  If nil, clears the rest of the mipmaps.",
+                      default = "nil"
+                    }
+                  },
+                  returns = {}
+                },
+                {
+                  arguments = {
+                    {
+                      name = "t",
+                      type = "table",
+                      description = "A table with color components."
+                    },
+                    {
+                      name = "layer",
+                      type = "number",
+                      description = "The index of the first layer to clear.",
+                      default = "1"
+                    },
+                    {
+                      name = "layerCount",
+                      type = "number",
+                      description = "The number of layers to clear.  If nil, clears the rest of the layers.",
+                      default = "nil"
+                    },
+                    {
+                      name = "mipmap",
+                      type = "number",
+                      description = "The index of the first mipmap to clear.",
+                      default = "1"
+                    },
+                    {
+                      name = "mipmapCount",
+                      type = "number",
+                      description = "The number of mipmaps to clear.  If nil, clears the rest of the mipmaps.",
+                      default = "nil"
+                    }
+                  },
+                  returns = {}
+                },
+                {
+                  arguments = {
+                    {
+                      name = "v3",
+                      type = "Vec3",
+                      description = "A vec3 with the clear color."
+                    },
+                    {
+                      name = "layer",
+                      type = "number",
+                      description = "The index of the first layer to clear.",
+                      default = "1"
+                    },
+                    {
+                      name = "layerCount",
+                      type = "number",
+                      description = "The number of layers to clear.  If nil, clears the rest of the layers.",
+                      default = "nil"
+                    },
+                    {
+                      name = "mipmap",
+                      type = "number",
+                      description = "The index of the first mipmap to clear.",
+                      default = "1"
+                    },
+                    {
+                      name = "mipmapCount",
+                      type = "number",
+                      description = "The number of mipmaps to clear.  If nil, clears the rest of the mipmaps.",
+                      default = "nil"
+                    }
+                  },
+                  returns = {}
+                },
+                {
+                  arguments = {
+                    {
+                      name = "v4",
+                      type = "Vec4",
+                      description = "A vec4 with the clear color."
+                    },
+                    {
+                      name = "layer",
+                      type = "number",
+                      description = "The index of the first layer to clear.",
+                      default = "1"
+                    },
+                    {
+                      name = "layerCount",
+                      type = "number",
+                      description = "The number of layers to clear.  If nil, clears the rest of the layers.",
+                      default = "nil"
+                    },
+                    {
+                      name = "mipmap",
+                      type = "number",
+                      description = "The index of the first mipmap to clear.",
+                      default = "1"
+                    },
+                    {
+                      name = "mipmapCount",
+                      type = "number",
+                      description = "The number of mipmaps to clear.  If nil, clears the rest of the mipmaps.",
+                      default = "nil"
+                    }
+                  },
+                  returns = {}
+                }
+              }
+            },
             {
               name = "getDimensions",
               summary = "Get the dimensions of the Texture.",

+ 101 - 0
api/lovr/graphics/Texture/clear.lua

@@ -0,0 +1,101 @@
+return {
+  summary = 'Clear the Texture to a color.',
+  description = [[
+    Clears layers and mipmaps in a texture to a given color.
+
+    When a Texture is being used as a canvas for a `Pass`, the clear color can be set with
+    `Pass:setClear`, which a more efficient way to clear the texture before rendering.
+  ]],
+  arguments = {
+    hex = {
+      type = 'number',
+      description = 'The hexcode color to clear to.'
+    },
+    r = {
+      type = 'number',
+      description = 'The red component of the clear color.'
+    },
+    g = {
+      type = 'number',
+      description = 'The green component of the clear color.'
+    },
+    b = {
+      type = 'number',
+      description = 'The blue component of the clear color.'
+    },
+    a = {
+      type = 'number',
+      description = 'The alpha component of the clear color.'
+    },
+    t = {
+      type = 'table',
+      description = 'A table with color components.'
+    },
+    v3 = {
+      type = 'Vec3',
+      description = 'A vec3 with the clear color.'
+    },
+    v4 = {
+      type = 'Vec4',
+      description = 'A vec4 with the clear color.'
+    },
+    layer = {
+      type = 'number',
+      default = '1',
+      description = 'The index of the first layer to clear.'
+    },
+    layerCount = {
+      type = 'number',
+      default = 'nil',
+      description = 'The number of layers to clear.  If nil, clears the rest of the layers.'
+    },
+    mipmap = {
+      type = 'number',
+      default = '1',
+      description = 'The index of the first mipmap to clear.'
+    },
+    mipmapCount = {
+      type = 'number',
+      default = 'nil',
+      description = 'The number of mipmaps to clear.  If nil, clears the rest of the mipmaps.'
+    }
+  },
+  returns = {},
+  variants = {
+    {
+      description = 'Clear the whole texture to zero (transparent black).',
+      arguments = {},
+      returns = {}
+    },
+    {
+      arguments = { 'hex', 'layer', 'layerCount', 'mipmap', 'mipmapCount' },
+      returns = {}
+    },
+    {
+      arguments = { 'r', 'g', 'b', 'a', 'layer', 'layerCount', 'mipmap', 'mipmapCount' },
+      returns = {}
+    },
+    {
+      arguments = { 't', 'layer', 'layerCount', 'mipmap', 'mipmapCount' },
+      returns = {}
+    },
+    {
+      arguments = { 'v3', 'layer', 'layerCount', 'mipmap', 'mipmapCount' },
+      returns = {}
+    },
+    {
+      arguments = { 'v4', 'layer', 'layerCount', 'mipmap', 'mipmapCount' },
+      returns = {}
+    }
+  },
+  notes = [[
+    The texture must have been created with the `transfer` usage to clear it.
+
+    The clear color will be interpreted as a linear color for sRGB formats.
+  ]],
+  related = {
+    'Buffer:clear',
+    'Texture:setPixels',
+    'Pass:setClear'
+  }
+}