Browse Source

Texture:generateMipmaps;

bjorn 1 year ago
parent
commit
31e5026348
2 changed files with 73 additions and 0 deletions
  1. 32 0
      api/init.lua
  2. 41 0
      api/lovr/graphics/Texture/generateMipmaps.lua

+ 32 - 0
api/init.lua

@@ -22934,6 +22934,38 @@ return {
                 }
               }
             },
+            {
+              name = "generateMipmaps",
+              tag = "texture-transfer",
+              summary = "Regenerate mipmaps for a Texture.",
+              description = "Regenerates mipmap levels of a texture.  This downscales pixels from the texture to progressively smaller sizes and saves them.  If the texture is drawn at a smaller scale later, the mipmaps are used, which smooths out the appearance and improves performance.",
+              key = "Texture:generateMipmaps",
+              module = "lovr.graphics",
+              notes = "The texture must have been created with the `transfer` usage to mipmap it.\n\nThe texture can not be multisampled.\n\nTexture views can not currently be mipmapped.",
+              related = {
+                "Texture:setPixels",
+                "Texture:getMipmapCount"
+              },
+              variants = {
+                {
+                  arguments = {
+                    {
+                      name = "base",
+                      type = "number",
+                      description = "The base mipmap level which will be used to generate subsequent mipmaps.",
+                      default = "1"
+                    },
+                    {
+                      name = "count",
+                      type = "number",
+                      description = "The number of mipmap levels to generate.  If nil, the rest of the mipmaps will be generated.",
+                      default = "nil"
+                    }
+                  },
+                  returns = {}
+                }
+              }
+            },
             {
               name = "getDimensions",
               tag = "texture-metadata",

+ 41 - 0
api/lovr/graphics/Texture/generateMipmaps.lua

@@ -0,0 +1,41 @@
+return {
+  tag = 'texture-transfer',
+  summary = 'Regenerate mipmaps for a Texture.',
+  description = [[
+    Regenerates mipmap levels of a texture.  This downscales pixels from the texture to
+    progressively smaller sizes and saves them.  If the texture is drawn at a smaller scale later,
+    the mipmaps are used, which smooths out the appearance and improves performance.
+  ]],
+  arguments = {
+    base = {
+      type = 'number',
+      default = '1',
+      description = 'The base mipmap level which will be used to generate subsequent mipmaps.'
+    },
+    count = {
+      type = 'number',
+      default = 'nil',
+      description = [[
+        The number of mipmap levels to generate.  If nil, the rest of the mipmaps will be generated.
+      ]]
+    }
+  },
+  returns = {},
+  variants = {
+    {
+      arguments = { 'base', 'count' },
+      returns = {}
+    }
+  },
+  notes = [[
+    The texture must have been created with the `transfer` usage to mipmap it.
+
+    The texture can not be multisampled.
+
+    Texture views can not currently be mipmapped.
+  ]],
+  related = {
+    'Texture:setPixels',
+    'Texture:getMipmapCount'
+  }
+}