Browse Source

Shader:hasBlock;

bjorn 4 years ago
parent
commit
b1dce90cb6

+ 34 - 2
api/init.lua

@@ -12945,13 +12945,43 @@ return {
                 }
                 }
               }
               }
             },
             },
+            {
+              name = "hasBlock",
+              summary = "Check if a Shader has a block.",
+              description = "Returns whether a Shader has a block.\n\nA block is added to the Shader code at creation time using `ShaderBlock:getShaderCode`.  The block name (not the namespace) is used to link up the ShaderBlock object to the Shader.  This function can be used to check if a Shader was created with a block using the given name.",
+              key = "Shader:hasBlock",
+              module = "lovr.graphics",
+              related = {
+                "Shader:sendBlock"
+              },
+              variants = {
+                {
+                  arguments = {
+                    {
+                      name = "block",
+                      type = "string",
+                      description = "The name of the block."
+                    }
+                  },
+                  returns = {
+                    {
+                      name = "present",
+                      type = "boolean",
+                      description = "Whether the shader has the specified block."
+                    }
+                  }
+                }
+              }
+            },
             {
             {
               name = "hasUniform",
               name = "hasUniform",
               summary = "Check if a Shader has a uniform variable.",
               summary = "Check if a Shader has a uniform variable.",
               description = "Returns whether a Shader has a particular uniform variable.",
               description = "Returns whether a Shader has a particular uniform variable.",
               key = "Shader:hasUniform",
               key = "Shader:hasUniform",
               module = "lovr.graphics",
               module = "lovr.graphics",
-              notes = "If a uniform variable is defined but unused in the shader, the shader compiler will optimize it out and the uniform will not report itself as present.",
+              related = {
+                "Shader:send"
+              },
               variants = {
               variants = {
                 {
                 {
                   arguments = {
                   arguments = {
@@ -12969,7 +12999,8 @@ return {
                     }
                     }
                   }
                   }
                 }
                 }
-              }
+              },
+              notes = "If a uniform variable is defined but unused in the shader, the shader compiler will optimize it out and the uniform will not report itself as present."
             },
             },
             {
             {
               name = "send",
               name = "send",
@@ -13013,6 +13044,7 @@ return {
               key = "Shader:sendBlock",
               key = "Shader:sendBlock",
               module = "lovr.graphics",
               module = "lovr.graphics",
               related = {
               related = {
+                "Shader:hasBlock",
                 "Shader:send",
                 "Shader:send",
                 "ShaderBlock:send",
                 "ShaderBlock:send",
                 "ShaderBlock:getShaderCode",
                 "ShaderBlock:getShaderCode",

+ 27 - 0
api/lovr/graphics/Shader/hasBlock.lua

@@ -0,0 +1,27 @@
+return {
+  summary = 'Check if a Shader has a block.',
+  description = [[
+    Returns whether a Shader has a block.
+
+    A block is added to the Shader code at creation time using `ShaderBlock:getShaderCode`.  The
+    block name (not the namespace) is used to link up the ShaderBlock object to the Shader.  This
+    function can be used to check if a Shader was created with a block using the given name.
+  ]],
+  arguments = {
+    {
+      name = 'block',
+      type = 'string',
+      description = 'The name of the block.'
+    }
+  },
+  returns = {
+    {
+      name = 'present',
+      type = 'boolean',
+      description = 'Whether the shader has the specified block.'
+    }
+  },
+  related = {
+    'Shader:sendBlock'
+  }
+}

+ 4 - 1
api/lovr/graphics/Shader/hasUniform.lua

@@ -18,5 +18,8 @@ return {
   notes = [[
   notes = [[
     If a uniform variable is defined but unused in the shader, the shader compiler will optimize it
     If a uniform variable is defined but unused in the shader, the shader compiler will optimize it
     out and the uniform will not report itself as present.
     out and the uniform will not report itself as present.
-  ]]
+  ]],
+  related = {
+    'Shader:send'
+  }
 }
 }

+ 1 - 0
api/lovr/graphics/Shader/sendBlock.lua

@@ -32,6 +32,7 @@ return {
     `ShaderBlock:getShaderCode` to get a GLSL snippet that is compatible with the block.
     `ShaderBlock:getShaderCode` to get a GLSL snippet that is compatible with the block.
   ]],
   ]],
   related = {
   related = {
+    'Shader:hasBlock',
     'Shader:send',
     'Shader:send',
     'ShaderBlock:send',
     'ShaderBlock:send',
     'ShaderBlock:getShaderCode',
     'ShaderBlock:getShaderCode',