MaterialManager.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. function MaterialManager() {
  2. Object.defineProperties(this, {
  3. 'premultiplyAlphaOnLoad': { enumerable: true, configurable: true, get: MaterialManager.prototype.__get_premultiplyAlphaOnLoad, set: MaterialManager.prototype.__set_premultiplyAlphaOnLoad},
  4. 'clampDefault': { enumerable: true, configurable: true, get: MaterialManager.prototype.__get_clampDefault, set: MaterialManager.prototype.__set_clampDefault},
  5. 'mipmapsDefault': { enumerable: true, configurable: true, get: MaterialManager.prototype.__get_mipmapsDefault, set: MaterialManager.prototype.__set_mipmapsDefault},
  6. 'keepTextureData': { enumerable: true, configurable: true, get: MaterialManager.prototype.__get_keepTextureData, set: MaterialManager.prototype.__set_keepTextureData}
  7. })
  8. }
  9. MaterialManager.prototype.__get_premultiplyAlphaOnLoad = function() {
  10. return Polycode.MaterialManager__get_premultiplyAlphaOnLoad(this.__ptr)
  11. }
  12. MaterialManager.prototype.__set_premultiplyAlphaOnLoad = function(val) {
  13. Polycode.MaterialManager__set_premultiplyAlphaOnLoad(this.__ptr, val)
  14. }
  15. MaterialManager.prototype.__get_clampDefault = function() {
  16. return Polycode.MaterialManager__get_clampDefault(this.__ptr)
  17. }
  18. MaterialManager.prototype.__set_clampDefault = function(val) {
  19. Polycode.MaterialManager__set_clampDefault(this.__ptr, val)
  20. }
  21. MaterialManager.prototype.__get_mipmapsDefault = function() {
  22. return Polycode.MaterialManager__get_mipmapsDefault(this.__ptr)
  23. }
  24. MaterialManager.prototype.__set_mipmapsDefault = function(val) {
  25. Polycode.MaterialManager__set_mipmapsDefault(this.__ptr, val)
  26. }
  27. MaterialManager.prototype.__get_keepTextureData = function() {
  28. return Polycode.MaterialManager__get_keepTextureData(this.__ptr)
  29. }
  30. MaterialManager.prototype.__set_keepTextureData = function(val) {
  31. Polycode.MaterialManager__set_keepTextureData(this.__ptr, val)
  32. }
  33. Duktape.fin(MaterialManager.prototype, function (x) {
  34. if (x === MaterialManager.prototype) {
  35. return;
  36. }
  37. Polycode.MaterialManager__delete(x.__ptr)
  38. })
  39. MaterialManager.prototype.Update = function(elapsed) {
  40. Polycode.MaterialManager_Update(this.__ptr, elapsed)
  41. }
  42. MaterialManager.prototype.createTexture = function(width,height,imageData,clamp,createMipmaps,type) {
  43. var retVal = new Texture()
  44. retVal.__ptr = Polycode.MaterialManager_createTexture(this.__ptr, width,height,imageData,clamp,createMipmaps,type)
  45. return retVal
  46. }
  47. MaterialManager.prototype.createNewTexture = function(width,height,clamp,createMipmaps,type) {
  48. var retVal = new Texture()
  49. retVal.__ptr = Polycode.MaterialManager_createNewTexture(this.__ptr, width,height,clamp,createMipmaps,type)
  50. return retVal
  51. }
  52. MaterialManager.prototype.createTextureFromImage = function(image,clamp,createMipmaps) {
  53. var retVal = new Texture()
  54. retVal.__ptr = Polycode.MaterialManager_createTextureFromImage(this.__ptr, image,clamp,createMipmaps)
  55. return retVal
  56. }
  57. MaterialManager.prototype.createTextureFromFile = function(fileName,clamp,createMipmaps,resourcePool) {
  58. var retVal = new Texture()
  59. retVal.__ptr = Polycode.MaterialManager_createTextureFromFile(this.__ptr, fileName,clamp,createMipmaps,resourcePool)
  60. return retVal
  61. }
  62. MaterialManager.prototype.deleteTexture = function(texture) {
  63. Polycode.MaterialManager_deleteTexture(this.__ptr, texture)
  64. }
  65. MaterialManager.prototype.reloadTextures = function() {
  66. Polycode.MaterialManager_reloadTextures(this.__ptr)
  67. }
  68. MaterialManager.prototype.reloadProgramsAndTextures = function() {
  69. Polycode.MaterialManager_reloadProgramsAndTextures(this.__ptr)
  70. }
  71. MaterialManager.prototype.reloadPrograms = function() {
  72. Polycode.MaterialManager_reloadPrograms(this.__ptr)
  73. }
  74. MaterialManager.prototype.getTextureByResourcePath = function(resourcePath) {
  75. var retVal = new Texture()
  76. retVal.__ptr = Polycode.MaterialManager_getTextureByResourcePath(this.__ptr, resourcePath)
  77. return retVal
  78. }
  79. MaterialManager.prototype.createProgramFromFile = function(programPath) {
  80. var retVal = new ShaderProgram()
  81. retVal.__ptr = Polycode.MaterialManager_createProgramFromFile(this.__ptr, programPath)
  82. return retVal
  83. }
  84. MaterialManager.prototype.loadMaterialLibraryIntoPool = function(pool,materialFile) {
  85. Polycode.MaterialManager_loadMaterialLibraryIntoPool(this.__ptr, pool,materialFile)
  86. }
  87. MaterialManager.prototype.cubemapFromXMLNode = function(node) {
  88. var retVal = new Cubemap()
  89. retVal.__ptr = Polycode.MaterialManager_cubemapFromXMLNode(this.__ptr, node)
  90. return retVal
  91. }
  92. MaterialManager.prototype.materialFromXMLNode = function(resourcePool,node) {
  93. var retVal = new Material()
  94. retVal.__ptr = Polycode.MaterialManager_materialFromXMLNode(this.__ptr, resourcePool,node)
  95. return retVal
  96. }
  97. MaterialManager.prototype.createMaterial = function(resourcePool,materialName,shaderName) {
  98. var retVal = new Material()
  99. retVal.__ptr = Polycode.MaterialManager_createMaterial(this.__ptr, resourcePool,materialName,shaderName)
  100. return retVal
  101. }
  102. MaterialManager.prototype.setShaderFromXMLNode = function(resourcePool,node) {
  103. var retVal = new Shader()
  104. retVal.__ptr = Polycode.MaterialManager_setShaderFromXMLNode(this.__ptr, resourcePool,node)
  105. return retVal
  106. }
  107. MaterialManager.prototype.createShaderFromXMLNode = function(resourcePool,node) {
  108. var retVal = new Shader()
  109. retVal.__ptr = Polycode.MaterialManager_createShaderFromXMLNode(this.__ptr, resourcePool,node)
  110. return retVal
  111. }
  112. MaterialManager.prototype.createShader = function(resourcePool,shaderType,name,vpName,fpName,screenShader) {
  113. var retVal = new Shader()
  114. retVal.__ptr = Polycode.MaterialManager_createShader(this.__ptr, resourcePool,shaderType,name,vpName,fpName,screenShader)
  115. return retVal
  116. }
  117. MaterialManager.prototype.loadMaterialsFromFile = function(resourcePool,fileName) {
  118. Polycode.MaterialManager_loadMaterialsFromFile(this.__ptr, resourcePool,fileName)
  119. }
  120. MaterialManager.prototype.loadShadersFromFile = function(resourcePool,fileName) {
  121. Polycode.MaterialManager_loadShadersFromFile(this.__ptr, resourcePool,fileName)
  122. }
  123. MaterialManager.prototype.loadCubemapsFromFile = function(fileName) {
  124. Polycode.MaterialManager_loadCubemapsFromFile(this.__ptr, fileName)
  125. }
  126. MaterialManager.prototype.setAnisotropyAmount = function(anisotropy) {
  127. Polycode.MaterialManager_setAnisotropyAmount(this.__ptr, anisotropy)
  128. }
  129. MaterialManager.prototype.setTextureFilteringMode = function(textureFilteringMode) {
  130. Polycode.MaterialManager_setTextureFilteringMode(this.__ptr, textureFilteringMode)
  131. }
  132. MaterialManager.prototype.getTextureFilteringMode = function() {
  133. return Polycode.MaterialManager_getTextureFilteringMode(this.__ptr)
  134. }
  135. MaterialManager.prototype.addMaterial = function(material) {
  136. Polycode.MaterialManager_addMaterial(this.__ptr, material)
  137. }
  138. MaterialManager.prototype.addShader = function(shader) {
  139. Polycode.MaterialManager_addShader(this.__ptr, shader)
  140. }
  141. MaterialManager.prototype.getNumShaders = function() {
  142. return Polycode.MaterialManager_getNumShaders(this.__ptr)
  143. }
  144. MaterialManager.prototype.getShaderByIndex = function(index) {
  145. var retVal = new Shader()
  146. retVal.__ptr = Polycode.MaterialManager_getShaderByIndex(this.__ptr, index)
  147. return retVal
  148. }