Browse Source

Update newTexture;

bjorn 7 years ago
parent
commit
69327c6da2
2 changed files with 75 additions and 1 deletions
  1. 53 0
      api/init.lua
  2. 22 1
      api/lovr/graphics/newTexture.lua

+ 53 - 0
api/init.lua

@@ -8501,6 +8501,59 @@ return {
                 }
               }
             },
+            {
+              description = "Creates a blank Texture with specified dimensions.  This saves memory if you're planning on rendering to the Texture using a Canvas or a compute shader, but the contents of the Texture will be initialized to random data.",
+              arguments = {
+                {
+                  name = "width",
+                  type = "number",
+                  description = "The width of the Texture."
+                },
+                {
+                  name = "height",
+                  type = "number",
+                  description = "The height of the Texture."
+                },
+                {
+                  name = "depth",
+                  type = "number",
+                  description = "The depth of the Texture."
+                },
+                {
+                  name = "flags",
+                  type = "table",
+                  description = "Optional settings for the texture.",
+                  table = {
+                    {
+                      name = "linear",
+                      type = "boolean",
+                      description = "Whether the texture is in linear color space instead of sRGB.",
+                      default = "false"
+                    },
+                    {
+                      name = "mipmaps",
+                      type = "boolean",
+                      description = "Whether mipmaps will be generated for the texture.",
+                      default = "true"
+                    },
+                    {
+                      name = "type",
+                      type = "TextureType",
+                      description = "The type of Texture to load the images into.  If nil, the type will be `2d` for a single image, `array` for a table of images with numeric keys, or `cube` for a table of images with string keys.",
+                      default = "nil"
+                    }
+                  },
+                  default = "{}"
+                }
+              },
+              returns = {
+                {
+                  name = "texture",
+                  type = "Texture",
+                  description = "The new Texture."
+                }
+              }
+            },
             {
               description = "Create a texture from a single Blob.",
               arguments = {

+ 22 - 1
api/lovr/graphics/newTexture.lua

@@ -3,6 +3,18 @@ return {
   summary = 'Create a new Texture.',
   description = 'Creates a new Texture from an image file.',
   arguments = {
+    width = {
+      type = 'number',
+      description = 'The width of the Texture.'
+    },
+    height = {
+      type = 'number',
+      description = 'The height of the Texture.'
+    },
+    depth = {
+      type = 'number',
+      description = 'The depth of the Texture.'
+    },
     filename = {
       type = 'string',
       description = 'The filename of the image to load.'
@@ -71,6 +83,15 @@ return {
       arguments = { 'images', 'flags' },
       returns = { 'texture' }
     },
+    {
+      description = [[
+        Creates a blank Texture with specified dimensions.  This saves memory if you're planning on
+        rendering to the Texture using a Canvas or a compute shader, but the contents of the Texture
+        will be initialized to random data.
+      ]],
+      arguments = { 'width', 'height', 'depth', 'flags' },
+      returns = { 'texture' }
+    },
     {
       description = 'Create a texture from a single Blob.',
       arguments = { 'blob', 'flags' },
@@ -80,7 +101,7 @@ return {
       description = 'Create a texture from a single TextureData.',
       arguments = { 'textureData', 'flags' },
       returns = { 'texture' }
-    },
+    }
   },
   notes = [[
     The "linear" flag should be set to true for textures that don't contain color information, such