Browse Source

Alpha sampling; Font:hasGlyphs;

bjorn 6 years ago
parent
commit
b4612490b3

+ 92 - 0
api/init.lua

@@ -7292,6 +7292,27 @@ return {
             }
           }
         },
+        {
+          name = "getAlphaSampling",
+          tag = "graphicsState",
+          summary = "Get whether alpha sampling (alpha to coverage) is enabled.",
+          description = "Returns whether or not alpha sampling is enabled.  Alpha sampling is also known as alpha-to-coverage.  When it is enabled, the alpha channel of a pixel is factored into how antialiasing is computed, so the edges of a transparent texture will be correctly antialiased.",
+          key = "lovr.graphics.getAlphaSampling",
+          module = "lovr.graphics",
+          variants = {
+            {
+              arguments = {},
+              returns = {
+                {
+                  name = "enabled",
+                  type = "boolean",
+                  description = "Whether or not alpha sampling is enabled."
+                }
+              }
+            }
+          },
+          notes = "- Alpha sampling is disabled by default.\n- This feature can be used for a cheap transparency effect, pixels with an alpha of zero will\n  have their depth value discarded, allowing things behind them to show through (normally you\n  have to sort objects or write a shader for this)."
+        },
         {
           name = "getBackgroundColor",
           tag = "graphicsState",
@@ -9389,6 +9410,27 @@ return {
           },
           notes = "Order matters when scaling, translating, and rotating the coordinate system."
         },
+        {
+          name = "setAlphaSampling",
+          tag = "graphicsState",
+          summary = "Enable or disable alpha sampling.",
+          description = "Enables or disables alpha sampling.  Alpha sampling is also known as alpha-to-coverage.  When it is enabled, the alpha channel of a pixel is factored into how antialiasing is computed, so the edges of a transparent texture will be correctly antialiased.",
+          key = "lovr.graphics.setAlphaSampling",
+          module = "lovr.graphics",
+          variants = {
+            {
+              arguments = {
+                {
+                  name = "enabled",
+                  type = "boolean",
+                  description = "Whether or not alpha sampling is enabled."
+                }
+              },
+              returns = {}
+            }
+          },
+          notes = "- Alpha sampling is disabled by default.\n- This feature can be used for a cheap transparency effect, pixels with an alpha of zero will\n  have their depth value discarded, allowing things behind them to show through (normally you\n  have to sort objects or write a shader for this)."
+        },
         {
           name = "setBackgroundColor",
           tag = "graphicsState",
@@ -9682,6 +9724,27 @@ return {
           },
           notes = "The default point size is `1.0`."
         },
+        {
+          name = "setProjection",
+          tag = "graphicsState",
+          summary = "Set the projection matrix.",
+          description = "Sets the projection matrix.",
+          key = "lovr.graphics.setProjection",
+          module = "lovr.graphics",
+          variants = {
+            {
+              arguments = {
+                {
+                  name = "projection",
+                  type = "mat4",
+                  description = "The projection matrix to use."
+                }
+              },
+              returns = {}
+            }
+          },
+          notes = "- The projection matrix will be set for both \"eyes\" of the camera.\n- This state is reset at the beginning and end of `lovr.headset.renderTo`."
+        },
         {
           name = "setShader",
           tag = "graphicsState",
@@ -11362,6 +11425,35 @@ return {
                 }
               }
             },
+            {
+              name = "hasGlyphs",
+              summary = "Check if a Font has a set of glyphs.",
+              description = "Returns whether the Font has a set of glyphs.  Any combination of strings and numbers (corresponding to character codes) can be specified.  This function will return true if the Font is able to render *all* of the glyphs.",
+              key = "Font:hasGlyphs",
+              module = "lovr.graphics",
+              related = {
+                "Rasterizer:hasGlyphs"
+              },
+              variants = {
+                {
+                  arguments = {
+                    {
+                      name = "...",
+                      type = "*",
+                      description = "Strings or numbers to test."
+                    }
+                  },
+                  returns = {
+                    {
+                      name = "has",
+                      type = "boolean",
+                      description = "Whether the Font has the glyphs."
+                    }
+                  }
+                }
+              },
+              notes = "It is a good idea to use this function when you're rendering an unknown or user-supplied string to avoid embarrassing crashes."
+            },
             {
               name = "setLineHeight",
               summary = "Set the line height of the Font.",

+ 29 - 0
api/lovr/graphics/Font/hasGlyphs.lua

@@ -0,0 +1,29 @@
+return {
+  summary = 'Check if a Font has a set of glyphs.',
+  description = [[
+    Returns whether the Font has a set of glyphs.  Any combination of strings and numbers
+    (corresponding to character codes) can be specified.  This function will return true if the
+    Font is able to render *all* of the glyphs.
+  ]],
+  arguments = {
+    {
+      name = '...',
+      type = '*',
+      description = 'Strings or numbers to test.'
+    }
+  },
+  returns = {
+    {
+      name = 'has',
+      type = 'boolean',
+      description = 'Whether the Font has the glyphs.'
+    }
+  },
+  notes = [[
+    It is a good idea to use this function when you're rendering an unknown or user-supplied string
+    to avoid embarrassing crashes.
+  ]],
+  related = {
+    'Rasterizer:hasGlyphs'
+  }
+}

+ 23 - 0
api/lovr/graphics/getAlphaSampling.lua

@@ -0,0 +1,23 @@
+return {
+  tag = 'graphicsState',
+  summary = 'Get whether alpha sampling (alpha to coverage) is enabled.',
+  description = [[
+    Returns whether or not alpha sampling is enabled.  Alpha sampling is also known as
+    alpha-to-coverage.  When it is enabled, the alpha channel of a pixel is factored into how
+    antialiasing is computed, so the edges of a transparent texture will be correctly antialiased.
+  ]],
+  arguments = {},
+  returns = {
+    {
+      name = 'enabled',
+      type = 'boolean',
+      description = 'Whether or not alpha sampling is enabled.'
+    }
+  },
+  notes = [[
+    - Alpha sampling is disabled by default.
+    - This feature can be used for a cheap transparency effect, pixels with an alpha of zero will
+      have their depth value discarded, allowing things behind them to show through (normally you
+      have to sort objects or write a shader for this).
+  ]]
+}

+ 23 - 0
api/lovr/graphics/setAlphaSampling.lua

@@ -0,0 +1,23 @@
+return {
+  tag = 'graphicsState',
+  summary = 'Enable or disable alpha sampling.',
+  description = [[
+    Enables or disables alpha sampling.  Alpha sampling is also known as alpha-to-coverage.  When it
+    is enabled, the alpha channel of a pixel is factored into how antialiasing is computed, so the
+    edges of a transparent texture will be correctly antialiased.
+  ]],
+  arguments = {
+    {
+      name = 'enabled',
+      type = 'boolean',
+      description = 'Whether or not alpha sampling is enabled.'
+    }
+  },
+  returns = {},
+  notes = [[
+    - Alpha sampling is disabled by default.
+    - This feature can be used for a cheap transparency effect, pixels with an alpha of zero will
+      have their depth value discarded, allowing things behind them to show through (normally you
+      have to sort objects or write a shader for this).
+  ]]
+}

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

@@ -0,0 +1,17 @@
+return {
+  tag = 'graphicsState',
+  summary = 'Set the projection matrix.',
+  description = 'Sets the projection matrix.',
+  arguments = {
+    {
+      name = 'projection',
+      type = 'mat4',
+      description = 'The projection matrix to use.'
+    }
+  },
+  returns = {},
+  notes = [[
+    - The projection matrix will be set for both "eyes" of the camera.
+    - This state is reset at the beginning and end of `lovr.headset.renderTo`.
+  ]]
+}