2
0

Cubemap.lua 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. require "Polycode/Resource"
  2. class "Cubemap" (Resource)
  3. Cubemap.CUBEMAP_XPOS = 0
  4. Cubemap.CUBEMAP_XNEG = 1
  5. Cubemap.CUBEMAP_YPOS = 2
  6. Cubemap.CUBEMAP_YNEG = 3
  7. Cubemap.CUBEMAP_ZPOS = 4
  8. Cubemap.CUBEMAP_ZNEG = 5
  9. function Cubemap:Cubemap(...)
  10. local arg = {...}
  11. if type(arg[1]) == "table" and count(arg) == 1 then
  12. if ""..arg[1].__classname == "Resource" then
  13. self.__ptr = arg[1].__ptr
  14. return
  15. end
  16. end
  17. for k,v in pairs(arg) do
  18. if type(v) == "table" then
  19. if v.__ptr ~= nil then
  20. arg[k] = v.__ptr
  21. end
  22. end
  23. end
  24. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  25. self.__ptr = Polycode.Cubemap(unpack(arg))
  26. end
  27. end
  28. function Cubemap:getTexture(index)
  29. local retVal = Polycode.Cubemap_getTexture(self.__ptr, index)
  30. if retVal == nil then return nil end
  31. local __c = _G["Texture"]("__skip_ptr__")
  32. __c.__ptr = retVal
  33. return __c
  34. end
  35. function Cubemap:setTexture(texture, index)
  36. local retVal = Polycode.Cubemap_setTexture(self.__ptr, texture.__ptr, index)
  37. end
  38. function Cubemap:recreateFromTextures()
  39. local retVal = Polycode.Cubemap_recreateFromTextures(self.__ptr)
  40. end
  41. function Cubemap:__delete()
  42. if self then Polycode.delete_Cubemap(self.__ptr) end
  43. end