Shader:hasAttribute

Returns whether the Shader has a vertex attribute, by name or location.


exists = Shader:hasAttribute(name)

Arguments

NameTypeDescription
namestring The name of an attribute.

Returns

NameTypeDescription
existsboolean Whether the Shader has the attribute.

exists = Shader:hasAttribute(location)

Arguments

NameTypeDescription
locationnumber The location of an attribute.

Returns

NameTypeDescription
existsboolean Whether the Shader has the attribute.

Example

function lovr.load()
  shader = lovr.graphics.newShader([[
    layout(location = 7) in uint coolAttribute;

    vec4 lovrmain() {
      return DefaultPosition;
    }
  ]], [[
    vec4 lovrmain() {
      return DefaultColor;
    }
  ]])

  print(shader:hasAttribute('coolAttribute')) --> true
  print(shader:hasAttribute(7)) --> true
  print(shader:hasAttribute(8)) --> false
end

See also