2
0

ScreenMesh.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 retVal == nil then return nil end
  28. if Polycore.__ptr_lookup[retVal] ~= nil then
  29. return Polycore.__ptr_lookup[retVal]
  30. else
  31. Polycore.__ptr_lookup[retVal] = Mesh("__skip_ptr__")
  32. Polycore.__ptr_lookup[retVal].__ptr = retVal
  33. return Polycore.__ptr_lookup[retVal]
  34. end
  35. end
  36. function ScreenMesh:getTexture()
  37. local retVal = Polycore.ScreenMesh_getTexture(self.__ptr)
  38. if retVal == nil then return nil end
  39. if Polycore.__ptr_lookup[retVal] ~= nil then
  40. return Polycore.__ptr_lookup[retVal]
  41. else
  42. Polycore.__ptr_lookup[retVal] = Texture("__skip_ptr__")
  43. Polycore.__ptr_lookup[retVal].__ptr = retVal
  44. return Polycore.__ptr_lookup[retVal]
  45. end
  46. end
  47. function ScreenMesh:loadTexture(fileName)
  48. local retVal = Polycore.ScreenMesh_loadTexture(self.__ptr, fileName.__ptr)
  49. end
  50. function ScreenMesh:setTexture(texture)
  51. local retVal = Polycore.ScreenMesh_setTexture(self.__ptr, texture.__ptr)
  52. end
  53. function ScreenMesh:__delete()
  54. Polycore.__ptr_lookup[self.__ptr] = nil
  55. Polycore.delete_ScreenMesh(self.__ptr)
  56. end