AttributeBinding.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. class "AttributeBinding"
  2. function AttributeBinding:__getvar(name)
  3. if name == "name" then
  4. return Polycode.AttributeBinding_get_name(self.__ptr)
  5. elseif name == "vertexData" then
  6. local retVal = Polycode.AttributeBinding_get_vertexData(self.__ptr)
  7. if retVal == nil then return nil end
  8. local __c = _G["VertexDataArray"]("__skip_ptr__")
  9. __c.__ptr = retVal
  10. return __c
  11. elseif name == "attribute" then
  12. local retVal = Polycode.AttributeBinding_get_attribute(self.__ptr)
  13. if retVal == nil then return nil end
  14. local __c = _G["ProgramAttribute"]("__skip_ptr__")
  15. __c.__ptr = retVal
  16. return __c
  17. elseif name == "enabled" then
  18. return Polycode.AttributeBinding_get_enabled(self.__ptr)
  19. end
  20. end
  21. function AttributeBinding:__setvar(name,value)
  22. if name == "name" then
  23. Polycode.AttributeBinding_set_name(self.__ptr, value)
  24. return true
  25. elseif name == "vertexData" then
  26. Polycode.AttributeBinding_set_vertexData(self.__ptr, value.__ptr)
  27. return true
  28. elseif name == "attribute" then
  29. Polycode.AttributeBinding_set_attribute(self.__ptr, value.__ptr)
  30. return true
  31. elseif name == "enabled" then
  32. Polycode.AttributeBinding_set_enabled(self.__ptr, value)
  33. return true
  34. end
  35. return false
  36. end
  37. function AttributeBinding:AttributeBinding(...)
  38. local arg = {...}
  39. for k,v in pairs(arg) do
  40. if type(v) == "table" then
  41. if v.__ptr ~= nil then
  42. arg[k] = v.__ptr
  43. end
  44. end
  45. end
  46. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  47. self.__ptr = Polycode.AttributeBinding(unpack(arg))
  48. end
  49. end
  50. function AttributeBinding:__delete()
  51. if self then Polycode.delete_AttributeBinding(self.__ptr) end
  52. end