ResourceManager.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. end
  13. end
  14. function ResourceManager:addResource(resource)
  15. local retVal = Polycore.ResourceManager_addResource(self.__ptr, resource.__ptr)
  16. end
  17. function ResourceManager:addDirResource(dirPath, recursive)
  18. local retVal = Polycore.ResourceManager_addDirResource(self.__ptr, dirPath, recursive)
  19. end
  20. function ResourceManager:addArchive(zipPath)
  21. local retVal = Polycore.ResourceManager_addArchive(self.__ptr, zipPath)
  22. end
  23. function ResourceManager:readFile(fileName)
  24. local retVal = Polycore.ResourceManager_readFile(self.__ptr, fileName)
  25. return retVal
  26. end
  27. function ResourceManager:parseTextures(dirPath, recursive)
  28. local retVal = Polycore.ResourceManager_parseTextures(self.__ptr, dirPath, recursive)
  29. end
  30. function ResourceManager:parseMaterials(dirPath, recursive)
  31. local retVal = Polycore.ResourceManager_parseMaterials(self.__ptr, dirPath, recursive)
  32. end
  33. function ResourceManager:parseShaders(dirPath, recursive)
  34. local retVal = Polycore.ResourceManager_parseShaders(self.__ptr, dirPath, recursive)
  35. end
  36. function ResourceManager:parsePrograms(dirPath, recursive)
  37. local retVal = Polycore.ResourceManager_parsePrograms(self.__ptr, dirPath, recursive)
  38. end
  39. function ResourceManager:parseCubemaps(dirPath, recursive)
  40. local retVal = Polycore.ResourceManager_parseCubemaps(self.__ptr, dirPath, recursive)
  41. end
  42. function ResourceManager:getResource(resourceType, resourceName)
  43. local retVal = Polycore.ResourceManager_getResource(self.__ptr, resourceType, resourceName)
  44. if Polycore.__ptr_lookup[retVal] ~= nil then
  45. return Polycore.__ptr_lookup[retVal]
  46. else
  47. Polycore.__ptr_lookup[retVal] = Resource("__skip_ptr__")
  48. Polycore.__ptr_lookup[retVal].__ptr = retVal
  49. return Polycore.__ptr_lookup[retVal]
  50. end
  51. end
  52. function ResourceManager:addShaderModule(module)
  53. local retVal = Polycore.ResourceManager_addShaderModule(self.__ptr, module.__ptr)
  54. end