AttributeBinding.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. class "AttributeBinding"
  2. function AttributeBinding:__getvar(name)
  3. if name == "name" then
  4. return Polycore.AttributeBinding_get_name(self.__ptr)
  5. elseif name == "vertexData" then
  6. local retVal = Polycore.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 = Polycore.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 Polycore.AttributeBinding_get_enabled(self.__ptr)
  19. end
  20. end
  21. function AttributeBinding:__setvar(name,value)
  22. if name == "name" then
  23. Polycore.AttributeBinding_set_name(self.__ptr, value)
  24. return true
  25. elseif name == "enabled" then
  26. Polycore.AttributeBinding_set_enabled(self.__ptr, value)
  27. return true
  28. end
  29. return false
  30. end
  31. function AttributeBinding:AttributeBinding(...)
  32. local arg = {...}
  33. for k,v in pairs(arg) do
  34. if type(v) == "table" then
  35. if v.__ptr ~= nil then
  36. arg[k] = v.__ptr
  37. end
  38. end
  39. end
  40. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  41. self.__ptr = Polycore.AttributeBinding(unpack(arg))
  42. end
  43. end
  44. function AttributeBinding:__delete()
  45. if self then Polycore.delete_AttributeBinding(self.__ptr) end
  46. end