Browse Source

More Shader:hasVariable docs;

bjorn 1 year ago
parent
commit
ae24136f07
2 changed files with 47 additions and 0 deletions
  1. 33 0
      api/init.lua
  2. 14 0
      api/lovr/graphics/Shader/hasVariable.lua

+ 33 - 0
api/init.lua

@@ -22812,6 +22812,39 @@ return {
                   }
                   }
                 }
                 }
               }
               }
+            },
+            {
+              name = "hasVariable",
+              summary = "Check if the Shader has a variable.",
+              description = "Returns whether the Shader has a variable.",
+              key = "Shader:hasVariable",
+              module = "lovr.graphics",
+              examples = {
+                {
+                  code = "for key, texture in pairs(textures) do\n  if shader:hasVariable(key) then\n    pass:send(key, texture)\n  end\nend"
+                }
+              },
+              notes = "This will return true if the variable is a buffer, texture, sampler, or other uniform variable (anything that can be sent with `Pass:send`).",
+              related = {
+                "Pass:send"
+              },
+              variants = {
+                {
+                  arguments = {
+                    {
+                      name = "name",
+                      type = "string"
+                    }
+                  },
+                  returns = {
+                    {
+                      name = "exists",
+                      type = "boolean",
+                      description = "Whether the Shader has the variable."
+                    }
+                  }
+                }
+              }
             }
             }
           }
           }
         },
         },

+ 14 - 0
api/lovr/graphics/Shader/hasVariable.lua

@@ -18,4 +18,18 @@ return {
       returns = { 'exists' }
       returns = { 'exists' }
     }
     }
   },
   },
+  notes = [[
+    This will return true if the variable is a buffer, texture, sampler, or other uniform variable
+    (anything that can be sent with `Pass:send`).
+  ]],
+  example = [[
+    for key, texture in pairs(textures) do
+      if shader:hasVariable(key) then
+        pass:send(key, texture)
+      end
+    end
+  ]],
+  related = {
+    'Pass:send'
+  }
 }
 }