ScreenMesh.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. require "Polycode/ScreenEntity"
  2. class "ScreenMesh" (ScreenEntity)
  3. function ScreenMesh:ScreenMesh(...)
  4. if type(arg[1]) == "table" and count(arg) == 1 then
  5. if ""..arg[1]:class() == "ScreenEntity" then
  6. self.__ptr = arg[1].__ptr
  7. return
  8. end
  9. end
  10. for k,v in pairs(arg) do
  11. if type(v) == "table" then
  12. if v.__ptr ~= nil then
  13. arg[k] = v.__ptr
  14. end
  15. end
  16. end
  17. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  18. self.__ptr = Polycore.ScreenMesh(unpack(arg))
  19. Polycore.__ptr_lookup[self.__ptr] = self
  20. end
  21. end
  22. function ScreenMesh:Render()
  23. local retVal = Polycore.ScreenMesh_Render(self.__ptr)
  24. end
  25. function ScreenMesh:getMesh()
  26. local retVal = Polycore.ScreenMesh_getMesh(self.__ptr)
  27. if Polycore.__ptr_lookup[retVal] ~= nil then
  28. return Polycore.__ptr_lookup[retVal]
  29. else
  30. Polycore.__ptr_lookup[retVal] = Mesh("__skip_ptr__")
  31. Polycore.__ptr_lookup[retVal].__ptr = retVal
  32. return Polycore.__ptr_lookup[retVal]
  33. end
  34. end
  35. function ScreenMesh:getTexture()
  36. local retVal = Polycore.ScreenMesh_getTexture(self.__ptr)
  37. if Polycore.__ptr_lookup[retVal] ~= nil then
  38. return Polycore.__ptr_lookup[retVal]
  39. else
  40. Polycore.__ptr_lookup[retVal] = Texture("__skip_ptr__")
  41. Polycore.__ptr_lookup[retVal].__ptr = retVal
  42. return Polycore.__ptr_lookup[retVal]
  43. end
  44. end
  45. function ScreenMesh:loadTexture(fileName)
  46. local retVal = Polycore.ScreenMesh_loadTexture(self.__ptr, fileName)
  47. end
  48. function ScreenMesh:setTexture(texture)
  49. local retVal = Polycore.ScreenMesh_setTexture(self.__ptr, texture.__ptr)
  50. end
  51. function ScreenMesh:__delete()
  52. Polycore.__ptr_lookup[self.__ptr] = nil
  53. Polycore.delete_ScreenMesh(self.__ptr)
  54. end