hasAttribute.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. return {
  2. summary = 'Check if the Shader has a given vertex attribute.',
  3. description = 'Returns whether the Shader has a vertex attribute, by name or location.',
  4. arguments = {
  5. name = {
  6. type = 'string',
  7. description = 'The name of an attribute.'
  8. },
  9. location = {
  10. type = 'number',
  11. description = 'The location of an attribute.'
  12. }
  13. },
  14. returns = {
  15. exists = {
  16. type = 'boolean',
  17. description = 'Whether the Shader has the attribute.'
  18. }
  19. },
  20. variants = {
  21. {
  22. arguments = { 'name' },
  23. returns = { 'exists' }
  24. },
  25. {
  26. arguments = { 'location' },
  27. returns = { 'exists' }
  28. }
  29. },
  30. example = [=[
  31. function lovr.load()
  32. shader = lovr.graphics.newShader([[
  33. layout(location = 7) in uint coolAttribute;
  34. vec4 lovrmain() {
  35. return DefaultPosition;
  36. }
  37. ]], [[
  38. vec4 lovrmain() {
  39. return DefaultColor;
  40. }
  41. ]])
  42. print(shader:hasAttribute('coolAttribute')) --> true
  43. print(shader:hasAttribute(7)) --> true
  44. print(shader:hasAttribute(8)) --> false
  45. end
  46. ]=]
  47. }