diff --git a/src/pixi/textures/BaseTexture.js b/src/pixi/textures/BaseTexture.js index 4535f3e..75031f4 100644 --- a/src/pixi/textures/BaseTexture.js +++ b/src/pixi/textures/BaseTexture.js @@ -168,19 +168,7 @@ } this.source = null; - // delete the webGL textures if any. - for (var i = this._glTextures.length - 1; i >= 0; i--) - { - var glTexture = this._glTextures[i]; - var gl = PIXI.glContexts[i]; - - if(gl && glTexture) - { - gl.deleteTexture(glTexture); - } - } - - this._glTextures.length = 0; + this.unloadFromGPU(); }; /** @@ -210,6 +198,29 @@ }; /** + * Removes the base texture from the GPU, useful for managing resources on the GPU. + * Atexture is still 100% usable and will simply be reuploaded if there is a sprite on screen that is using it. + * + * @method unloadFromGPU + */ +PIXI.BaseTexture.unloadFromGPU = function() +{ + // delete the webGL textures if any. + for (var i = this._glTextures.length - 1; i >= 0; i--) + { + var glTexture = this._glTextures[i]; + var gl = PIXI.glContexts[i]; + + if(gl && glTexture) + { + gl.deleteTexture(glTexture); + } + } + + this._glTextures.length = 0; +} + +/** * Helper function that creates a base texture from the given image url. * If the image is not in the base texture cache it will be created and loaded. *