ResourceManager.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. class "ResourceManager"
  2. function ResourceManager:ResourceManager(...)
  3. for k,v in pairs(arg) do
  4. if type(v) == "table" then
  5. if v.__ptr ~= nil then
  6. arg[k] = v.__ptr
  7. end
  8. end
  9. end
  10. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  11. self.__ptr = Polycore.ResourceManager(unpack(arg))
  12. Polycore.__ptr_lookup[self.__ptr] = self
  13. end
  14. end
  15. function ResourceManager:addResource(resource)
  16. local retVal = Polycore.ResourceManager_addResource(self.__ptr, resource.__ptr)
  17. end
  18. function ResourceManager:addDirResource(dirPath, recursive)
  19. local retVal = Polycore.ResourceManager_addDirResource(self.__ptr, dirPath, recursive)
  20. end
  21. function ResourceManager:addArchive(zipPath)
  22. local retVal = Polycore.ResourceManager_addArchive(self.__ptr, zipPath)
  23. end
  24. function ResourceManager:readFile(fileName)
  25. local retVal = Polycore.ResourceManager_readFile(self.__ptr, fileName)
  26. return retVal
  27. end
  28. function ResourceManager:parseTextures(dirPath, recursive)
  29. local retVal = Polycore.ResourceManager_parseTextures(self.__ptr, dirPath, recursive)
  30. end
  31. function ResourceManager:parseMaterials(dirPath, recursive)
  32. local retVal = Polycore.ResourceManager_parseMaterials(self.__ptr, dirPath, recursive)
  33. end
  34. function ResourceManager:parseShaders(dirPath, recursive)
  35. local retVal = Polycore.ResourceManager_parseShaders(self.__ptr, dirPath, recursive)
  36. end
  37. function ResourceManager:parsePrograms(dirPath, recursive)
  38. local retVal = Polycore.ResourceManager_parsePrograms(self.__ptr, dirPath, recursive)
  39. end
  40. function ResourceManager:parseCubemaps(dirPath, recursive)
  41. local retVal = Polycore.ResourceManager_parseCubemaps(self.__ptr, dirPath, recursive)
  42. end
  43. function ResourceManager:parseOthers(dirPath, recursive)
  44. local retVal = Polycore.ResourceManager_parseOthers(self.__ptr, dirPath, recursive)
  45. end
  46. function ResourceManager:getResource(resourceType, resourceName)
  47. local retVal = Polycore.ResourceManager_getResource(self.__ptr, resourceType, resourceName)
  48. if Polycore.__ptr_lookup[retVal] ~= nil then
  49. return Polycore.__ptr_lookup[retVal]
  50. else
  51. Polycore.__ptr_lookup[retVal] = Resource("__skip_ptr__")
  52. Polycore.__ptr_lookup[retVal].__ptr = retVal
  53. return Polycore.__ptr_lookup[retVal]
  54. end
  55. end
  56. function ResourceManager:addShaderModule(module)
  57. local retVal = Polycore.ResourceManager_addShaderModule(self.__ptr, module.__ptr)
  58. end
  59. function ResourceManager:__delete()
  60. Polycore.__ptr_lookup[self.__ptr] = nil
  61. Polycore.delete_ResourceManager(self.__ptr)
  62. end