diff --git a/bin/pixi.dev.js b/bin/pixi.dev.js index 9dee4e4..17ab7cd 100644 --- a/bin/pixi.dev.js +++ b/bin/pixi.dev.js @@ -4,7 +4,7 @@ * Copyright (c) 2012, Mat Groves * http://goodboydigital.com/ * - * Compiled: 2014-01-23 + * Compiled: 2014-01-24 * * pixi.js is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license.php @@ -4384,6 +4384,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -4407,6 +4416,8 @@ + + /** * @author Mat Groves http://matgroves.com/ @Doormat23 * @author Richard Davey http://www.photonstorm.com @photonstorm @@ -4529,6 +4540,14 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 @@ -4666,6 +4685,16 @@ this.program = program; }; +PIXI.PrimitiveShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + + this.attribute = null +}; + /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5675,11 +5704,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; @@ -5751,6 +5785,12 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; + +PIXI.WebGLMaskManager.prototype.destroy = function() +{ + this.maskStack = null; + this.gl = null; +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5784,22 +5824,8 @@ // this shader is used for the fast sprite rendering this.fastShader = new PIXI.PixiFastShader(gl); -// var shaderProgram = this.defaultShader.program; this.activateShader(this.defaultShader); -/* - gl.useProgram(shaderProgram); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - // console.log(">>") - // - // alert(this.defaultShader.aPositionCoord) - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord); - gl.enableVertexAttribArray(this.defaultShader.aScale); - gl.enableVertexAttribArray(this.defaultShader.aRotation);*/ - }; @@ -5864,13 +5890,7 @@ gl.useProgram(this.primitiveShader.program); this.setAttribs(this.primitiveShader.attributes); - /* - gl.disableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.disableVertexAttribArray(this.defaultShader.colorAttribute); - gl.disableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.enableVertexAttribArray(this.primitiveShader.colorAttribute);*/ + }; PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() @@ -5880,16 +5900,24 @@ gl.useProgram(this.defaultShader.program); this.setAttribs(this.defaultShader.attributes); -/* - gl.disableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.disableVertexAttribArray(this.primitiveShader.colorAttribute); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord);*/ }; + +PIXI.WebGLShaderManager.prototype.destroy = function(gl) +{ + this.attribState = null; + + this.tempAttribState = null; + + this.primitiveShader.destroy() + + this.defaultShader.destroy() + + this.fastShader.destroy() + + this.gl = null +}; + + /** * @author Mat Groves * @@ -6281,7 +6309,40 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +PIXI.WebGLSpriteBatch.prototype.destroy = function() +{ + this.vertices = null; + this.indices = null; + + this.gl.deleteBuffer( this.vertexBuffer ); + this.gl.deleteBuffer( this.indexBuffer ); + + this.currentBaseTexture = null; + + this.gl = null +}; + +PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) +{ + this.gl = gl; + + // create a couple of buffers + this.vertexBuffer = gl.createBuffer(); + this.indexBuffer = gl.createBuffer(); + + // 65535 is max index, so 65535 / 6 = 10922. + + + //upload the index data + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this.vertices, gl.DYNAMIC_DRAW); + + this.currentBlendMode = 99999; +} /** * @author Mat Groves diff --git a/bin/pixi.dev.js b/bin/pixi.dev.js index 9dee4e4..17ab7cd 100644 --- a/bin/pixi.dev.js +++ b/bin/pixi.dev.js @@ -4,7 +4,7 @@ * Copyright (c) 2012, Mat Groves * http://goodboydigital.com/ * - * Compiled: 2014-01-23 + * Compiled: 2014-01-24 * * pixi.js is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license.php @@ -4384,6 +4384,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -4407,6 +4416,8 @@ + + /** * @author Mat Groves http://matgroves.com/ @Doormat23 * @author Richard Davey http://www.photonstorm.com @photonstorm @@ -4529,6 +4540,14 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 @@ -4666,6 +4685,16 @@ this.program = program; }; +PIXI.PrimitiveShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + + this.attribute = null +}; + /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5675,11 +5704,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; @@ -5751,6 +5785,12 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; + +PIXI.WebGLMaskManager.prototype.destroy = function() +{ + this.maskStack = null; + this.gl = null; +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5784,22 +5824,8 @@ // this shader is used for the fast sprite rendering this.fastShader = new PIXI.PixiFastShader(gl); -// var shaderProgram = this.defaultShader.program; this.activateShader(this.defaultShader); -/* - gl.useProgram(shaderProgram); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - // console.log(">>") - // - // alert(this.defaultShader.aPositionCoord) - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord); - gl.enableVertexAttribArray(this.defaultShader.aScale); - gl.enableVertexAttribArray(this.defaultShader.aRotation);*/ - }; @@ -5864,13 +5890,7 @@ gl.useProgram(this.primitiveShader.program); this.setAttribs(this.primitiveShader.attributes); - /* - gl.disableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.disableVertexAttribArray(this.defaultShader.colorAttribute); - gl.disableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.enableVertexAttribArray(this.primitiveShader.colorAttribute);*/ + }; PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() @@ -5880,16 +5900,24 @@ gl.useProgram(this.defaultShader.program); this.setAttribs(this.defaultShader.attributes); -/* - gl.disableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.disableVertexAttribArray(this.primitiveShader.colorAttribute); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord);*/ }; + +PIXI.WebGLShaderManager.prototype.destroy = function(gl) +{ + this.attribState = null; + + this.tempAttribState = null; + + this.primitiveShader.destroy() + + this.defaultShader.destroy() + + this.fastShader.destroy() + + this.gl = null +}; + + /** * @author Mat Groves * @@ -6281,7 +6309,40 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +PIXI.WebGLSpriteBatch.prototype.destroy = function() +{ + this.vertices = null; + this.indices = null; + + this.gl.deleteBuffer( this.vertexBuffer ); + this.gl.deleteBuffer( this.indexBuffer ); + + this.currentBaseTexture = null; + + this.gl = null +}; + +PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) +{ + this.gl = gl; + + // create a couple of buffers + this.vertexBuffer = gl.createBuffer(); + this.indexBuffer = gl.createBuffer(); + + // 65535 is max index, so 65535 / 6 = 10922. + + + //upload the index data + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this.vertices, gl.DYNAMIC_DRAW); + + this.currentBlendMode = 99999; +} /** * @author Mat Groves diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index 325cdb9..0475ed5 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -465,11 +465,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; diff --git a/bin/pixi.dev.js b/bin/pixi.dev.js index 9dee4e4..17ab7cd 100644 --- a/bin/pixi.dev.js +++ b/bin/pixi.dev.js @@ -4,7 +4,7 @@ * Copyright (c) 2012, Mat Groves * http://goodboydigital.com/ * - * Compiled: 2014-01-23 + * Compiled: 2014-01-24 * * pixi.js is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license.php @@ -4384,6 +4384,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -4407,6 +4416,8 @@ + + /** * @author Mat Groves http://matgroves.com/ @Doormat23 * @author Richard Davey http://www.photonstorm.com @photonstorm @@ -4529,6 +4540,14 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 @@ -4666,6 +4685,16 @@ this.program = program; }; +PIXI.PrimitiveShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + + this.attribute = null +}; + /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5675,11 +5704,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; @@ -5751,6 +5785,12 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; + +PIXI.WebGLMaskManager.prototype.destroy = function() +{ + this.maskStack = null; + this.gl = null; +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5784,22 +5824,8 @@ // this shader is used for the fast sprite rendering this.fastShader = new PIXI.PixiFastShader(gl); -// var shaderProgram = this.defaultShader.program; this.activateShader(this.defaultShader); -/* - gl.useProgram(shaderProgram); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - // console.log(">>") - // - // alert(this.defaultShader.aPositionCoord) - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord); - gl.enableVertexAttribArray(this.defaultShader.aScale); - gl.enableVertexAttribArray(this.defaultShader.aRotation);*/ - }; @@ -5864,13 +5890,7 @@ gl.useProgram(this.primitiveShader.program); this.setAttribs(this.primitiveShader.attributes); - /* - gl.disableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.disableVertexAttribArray(this.defaultShader.colorAttribute); - gl.disableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.enableVertexAttribArray(this.primitiveShader.colorAttribute);*/ + }; PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() @@ -5880,16 +5900,24 @@ gl.useProgram(this.defaultShader.program); this.setAttribs(this.defaultShader.attributes); -/* - gl.disableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.disableVertexAttribArray(this.primitiveShader.colorAttribute); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord);*/ }; + +PIXI.WebGLShaderManager.prototype.destroy = function(gl) +{ + this.attribState = null; + + this.tempAttribState = null; + + this.primitiveShader.destroy() + + this.defaultShader.destroy() + + this.fastShader.destroy() + + this.gl = null +}; + + /** * @author Mat Groves * @@ -6281,7 +6309,40 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +PIXI.WebGLSpriteBatch.prototype.destroy = function() +{ + this.vertices = null; + this.indices = null; + + this.gl.deleteBuffer( this.vertexBuffer ); + this.gl.deleteBuffer( this.indexBuffer ); + + this.currentBaseTexture = null; + + this.gl = null +}; + +PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) +{ + this.gl = gl; + + // create a couple of buffers + this.vertexBuffer = gl.createBuffer(); + this.indexBuffer = gl.createBuffer(); + + // 65535 is max index, so 65535 / 6 = 10922. + + + //upload the index data + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this.vertices, gl.DYNAMIC_DRAW); + + this.currentBlendMode = 99999; +} /** * @author Mat Groves diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index 325cdb9..0475ed5 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -465,11 +465,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index eb4c520..d516e11 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -120,3 +120,11 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} diff --git a/bin/pixi.dev.js b/bin/pixi.dev.js index 9dee4e4..17ab7cd 100644 --- a/bin/pixi.dev.js +++ b/bin/pixi.dev.js @@ -4,7 +4,7 @@ * Copyright (c) 2012, Mat Groves * http://goodboydigital.com/ * - * Compiled: 2014-01-23 + * Compiled: 2014-01-24 * * pixi.js is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license.php @@ -4384,6 +4384,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -4407,6 +4416,8 @@ + + /** * @author Mat Groves http://matgroves.com/ @Doormat23 * @author Richard Davey http://www.photonstorm.com @photonstorm @@ -4529,6 +4540,14 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 @@ -4666,6 +4685,16 @@ this.program = program; }; +PIXI.PrimitiveShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + + this.attribute = null +}; + /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5675,11 +5704,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; @@ -5751,6 +5785,12 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; + +PIXI.WebGLMaskManager.prototype.destroy = function() +{ + this.maskStack = null; + this.gl = null; +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5784,22 +5824,8 @@ // this shader is used for the fast sprite rendering this.fastShader = new PIXI.PixiFastShader(gl); -// var shaderProgram = this.defaultShader.program; this.activateShader(this.defaultShader); -/* - gl.useProgram(shaderProgram); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - // console.log(">>") - // - // alert(this.defaultShader.aPositionCoord) - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord); - gl.enableVertexAttribArray(this.defaultShader.aScale); - gl.enableVertexAttribArray(this.defaultShader.aRotation);*/ - }; @@ -5864,13 +5890,7 @@ gl.useProgram(this.primitiveShader.program); this.setAttribs(this.primitiveShader.attributes); - /* - gl.disableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.disableVertexAttribArray(this.defaultShader.colorAttribute); - gl.disableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.enableVertexAttribArray(this.primitiveShader.colorAttribute);*/ + }; PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() @@ -5880,16 +5900,24 @@ gl.useProgram(this.defaultShader.program); this.setAttribs(this.defaultShader.attributes); -/* - gl.disableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.disableVertexAttribArray(this.primitiveShader.colorAttribute); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord);*/ }; + +PIXI.WebGLShaderManager.prototype.destroy = function(gl) +{ + this.attribState = null; + + this.tempAttribState = null; + + this.primitiveShader.destroy() + + this.defaultShader.destroy() + + this.fastShader.destroy() + + this.gl = null +}; + + /** * @author Mat Groves * @@ -6281,7 +6309,40 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +PIXI.WebGLSpriteBatch.prototype.destroy = function() +{ + this.vertices = null; + this.indices = null; + + this.gl.deleteBuffer( this.vertexBuffer ); + this.gl.deleteBuffer( this.indexBuffer ); + + this.currentBaseTexture = null; + + this.gl = null +}; + +PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) +{ + this.gl = gl; + + // create a couple of buffers + this.vertexBuffer = gl.createBuffer(); + this.indexBuffer = gl.createBuffer(); + + // 65535 is max index, so 65535 / 6 = 10922. + + + //upload the index data + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this.vertices, gl.DYNAMIC_DRAW); + + this.currentBlendMode = 99999; +} /** * @author Mat Groves diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index 325cdb9..0475ed5 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -465,11 +465,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index eb4c520..d516e11 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -120,3 +120,11 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index cae7ae6..1ce8253 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -297,6 +297,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -319,3 +328,5 @@ ]; + + diff --git a/bin/pixi.dev.js b/bin/pixi.dev.js index 9dee4e4..17ab7cd 100644 --- a/bin/pixi.dev.js +++ b/bin/pixi.dev.js @@ -4,7 +4,7 @@ * Copyright (c) 2012, Mat Groves * http://goodboydigital.com/ * - * Compiled: 2014-01-23 + * Compiled: 2014-01-24 * * pixi.js is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license.php @@ -4384,6 +4384,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -4407,6 +4416,8 @@ + + /** * @author Mat Groves http://matgroves.com/ @Doormat23 * @author Richard Davey http://www.photonstorm.com @photonstorm @@ -4529,6 +4540,14 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 @@ -4666,6 +4685,16 @@ this.program = program; }; +PIXI.PrimitiveShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + + this.attribute = null +}; + /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5675,11 +5704,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; @@ -5751,6 +5785,12 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; + +PIXI.WebGLMaskManager.prototype.destroy = function() +{ + this.maskStack = null; + this.gl = null; +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5784,22 +5824,8 @@ // this shader is used for the fast sprite rendering this.fastShader = new PIXI.PixiFastShader(gl); -// var shaderProgram = this.defaultShader.program; this.activateShader(this.defaultShader); -/* - gl.useProgram(shaderProgram); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - // console.log(">>") - // - // alert(this.defaultShader.aPositionCoord) - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord); - gl.enableVertexAttribArray(this.defaultShader.aScale); - gl.enableVertexAttribArray(this.defaultShader.aRotation);*/ - }; @@ -5864,13 +5890,7 @@ gl.useProgram(this.primitiveShader.program); this.setAttribs(this.primitiveShader.attributes); - /* - gl.disableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.disableVertexAttribArray(this.defaultShader.colorAttribute); - gl.disableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.enableVertexAttribArray(this.primitiveShader.colorAttribute);*/ + }; PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() @@ -5880,16 +5900,24 @@ gl.useProgram(this.defaultShader.program); this.setAttribs(this.defaultShader.attributes); -/* - gl.disableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.disableVertexAttribArray(this.primitiveShader.colorAttribute); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord);*/ }; + +PIXI.WebGLShaderManager.prototype.destroy = function(gl) +{ + this.attribState = null; + + this.tempAttribState = null; + + this.primitiveShader.destroy() + + this.defaultShader.destroy() + + this.fastShader.destroy() + + this.gl = null +}; + + /** * @author Mat Groves * @@ -6281,7 +6309,40 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +PIXI.WebGLSpriteBatch.prototype.destroy = function() +{ + this.vertices = null; + this.indices = null; + + this.gl.deleteBuffer( this.vertexBuffer ); + this.gl.deleteBuffer( this.indexBuffer ); + + this.currentBaseTexture = null; + + this.gl = null +}; + +PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) +{ + this.gl = gl; + + // create a couple of buffers + this.vertexBuffer = gl.createBuffer(); + this.indexBuffer = gl.createBuffer(); + + // 65535 is max index, so 65535 / 6 = 10922. + + + //upload the index data + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this.vertices, gl.DYNAMIC_DRAW); + + this.currentBlendMode = 99999; +} /** * @author Mat Groves diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index 325cdb9..0475ed5 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -465,11 +465,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index eb4c520..d516e11 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -120,3 +120,11 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index cae7ae6..1ce8253 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -297,6 +297,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -319,3 +328,5 @@ ]; + + diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index ecb1880..d3df036 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -65,3 +65,13 @@ this.program = program; }; + +PIXI.PrimitiveShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + + this.attribute = null +}; diff --git a/bin/pixi.dev.js b/bin/pixi.dev.js index 9dee4e4..17ab7cd 100644 --- a/bin/pixi.dev.js +++ b/bin/pixi.dev.js @@ -4,7 +4,7 @@ * Copyright (c) 2012, Mat Groves * http://goodboydigital.com/ * - * Compiled: 2014-01-23 + * Compiled: 2014-01-24 * * pixi.js is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license.php @@ -4384,6 +4384,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -4407,6 +4416,8 @@ + + /** * @author Mat Groves http://matgroves.com/ @Doormat23 * @author Richard Davey http://www.photonstorm.com @photonstorm @@ -4529,6 +4540,14 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 @@ -4666,6 +4685,16 @@ this.program = program; }; +PIXI.PrimitiveShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + + this.attribute = null +}; + /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5675,11 +5704,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; @@ -5751,6 +5785,12 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; + +PIXI.WebGLMaskManager.prototype.destroy = function() +{ + this.maskStack = null; + this.gl = null; +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5784,22 +5824,8 @@ // this shader is used for the fast sprite rendering this.fastShader = new PIXI.PixiFastShader(gl); -// var shaderProgram = this.defaultShader.program; this.activateShader(this.defaultShader); -/* - gl.useProgram(shaderProgram); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - // console.log(">>") - // - // alert(this.defaultShader.aPositionCoord) - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord); - gl.enableVertexAttribArray(this.defaultShader.aScale); - gl.enableVertexAttribArray(this.defaultShader.aRotation);*/ - }; @@ -5864,13 +5890,7 @@ gl.useProgram(this.primitiveShader.program); this.setAttribs(this.primitiveShader.attributes); - /* - gl.disableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.disableVertexAttribArray(this.defaultShader.colorAttribute); - gl.disableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.enableVertexAttribArray(this.primitiveShader.colorAttribute);*/ + }; PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() @@ -5880,16 +5900,24 @@ gl.useProgram(this.defaultShader.program); this.setAttribs(this.defaultShader.attributes); -/* - gl.disableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.disableVertexAttribArray(this.primitiveShader.colorAttribute); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord);*/ }; + +PIXI.WebGLShaderManager.prototype.destroy = function(gl) +{ + this.attribState = null; + + this.tempAttribState = null; + + this.primitiveShader.destroy() + + this.defaultShader.destroy() + + this.fastShader.destroy() + + this.gl = null +}; + + /** * @author Mat Groves * @@ -6281,7 +6309,40 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +PIXI.WebGLSpriteBatch.prototype.destroy = function() +{ + this.vertices = null; + this.indices = null; + + this.gl.deleteBuffer( this.vertexBuffer ); + this.gl.deleteBuffer( this.indexBuffer ); + + this.currentBaseTexture = null; + + this.gl = null +}; + +PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) +{ + this.gl = gl; + + // create a couple of buffers + this.vertexBuffer = gl.createBuffer(); + this.indexBuffer = gl.createBuffer(); + + // 65535 is max index, so 65535 / 6 = 10922. + + + //upload the index data + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this.vertices, gl.DYNAMIC_DRAW); + + this.currentBlendMode = 99999; +} /** * @author Mat Groves diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index 325cdb9..0475ed5 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -465,11 +465,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index eb4c520..d516e11 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -120,3 +120,11 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index cae7ae6..1ce8253 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -297,6 +297,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -319,3 +328,5 @@ ]; + + diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index ecb1880..d3df036 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -65,3 +65,13 @@ this.program = program; }; + +PIXI.PrimitiveShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + + this.attribute = null +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index 8e6f46c..0fc75fb 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -60,4 +60,10 @@ } if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); -}; \ No newline at end of file +}; + +PIXI.WebGLMaskManager.prototype.destroy = function() +{ + this.maskStack = null; + this.gl = null; +} \ No newline at end of file diff --git a/bin/pixi.dev.js b/bin/pixi.dev.js index 9dee4e4..17ab7cd 100644 --- a/bin/pixi.dev.js +++ b/bin/pixi.dev.js @@ -4,7 +4,7 @@ * Copyright (c) 2012, Mat Groves * http://goodboydigital.com/ * - * Compiled: 2014-01-23 + * Compiled: 2014-01-24 * * pixi.js is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license.php @@ -4384,6 +4384,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -4407,6 +4416,8 @@ + + /** * @author Mat Groves http://matgroves.com/ @Doormat23 * @author Richard Davey http://www.photonstorm.com @photonstorm @@ -4529,6 +4540,14 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 @@ -4666,6 +4685,16 @@ this.program = program; }; +PIXI.PrimitiveShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + + this.attribute = null +}; + /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5675,11 +5704,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; @@ -5751,6 +5785,12 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; + +PIXI.WebGLMaskManager.prototype.destroy = function() +{ + this.maskStack = null; + this.gl = null; +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5784,22 +5824,8 @@ // this shader is used for the fast sprite rendering this.fastShader = new PIXI.PixiFastShader(gl); -// var shaderProgram = this.defaultShader.program; this.activateShader(this.defaultShader); -/* - gl.useProgram(shaderProgram); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - // console.log(">>") - // - // alert(this.defaultShader.aPositionCoord) - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord); - gl.enableVertexAttribArray(this.defaultShader.aScale); - gl.enableVertexAttribArray(this.defaultShader.aRotation);*/ - }; @@ -5864,13 +5890,7 @@ gl.useProgram(this.primitiveShader.program); this.setAttribs(this.primitiveShader.attributes); - /* - gl.disableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.disableVertexAttribArray(this.defaultShader.colorAttribute); - gl.disableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.enableVertexAttribArray(this.primitiveShader.colorAttribute);*/ + }; PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() @@ -5880,16 +5900,24 @@ gl.useProgram(this.defaultShader.program); this.setAttribs(this.defaultShader.attributes); -/* - gl.disableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.disableVertexAttribArray(this.primitiveShader.colorAttribute); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord);*/ }; + +PIXI.WebGLShaderManager.prototype.destroy = function(gl) +{ + this.attribState = null; + + this.tempAttribState = null; + + this.primitiveShader.destroy() + + this.defaultShader.destroy() + + this.fastShader.destroy() + + this.gl = null +}; + + /** * @author Mat Groves * @@ -6281,7 +6309,40 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +PIXI.WebGLSpriteBatch.prototype.destroy = function() +{ + this.vertices = null; + this.indices = null; + + this.gl.deleteBuffer( this.vertexBuffer ); + this.gl.deleteBuffer( this.indexBuffer ); + + this.currentBaseTexture = null; + + this.gl = null +}; + +PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) +{ + this.gl = gl; + + // create a couple of buffers + this.vertexBuffer = gl.createBuffer(); + this.indexBuffer = gl.createBuffer(); + + // 65535 is max index, so 65535 / 6 = 10922. + + + //upload the index data + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this.vertices, gl.DYNAMIC_DRAW); + + this.currentBlendMode = 99999; +} /** * @author Mat Groves diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index 325cdb9..0475ed5 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -465,11 +465,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index eb4c520..d516e11 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -120,3 +120,11 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index cae7ae6..1ce8253 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -297,6 +297,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -319,3 +328,5 @@ ]; + + diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index ecb1880..d3df036 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -65,3 +65,13 @@ this.program = program; }; + +PIXI.PrimitiveShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + + this.attribute = null +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index 8e6f46c..0fc75fb 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -60,4 +60,10 @@ } if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); -}; \ No newline at end of file +}; + +PIXI.WebGLMaskManager.prototype.destroy = function() +{ + this.maskStack = null; + this.gl = null; +} \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js index 845504d..1984f04 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js @@ -31,22 +31,8 @@ // this shader is used for the fast sprite rendering this.fastShader = new PIXI.PixiFastShader(gl); -// var shaderProgram = this.defaultShader.program; this.activateShader(this.defaultShader); -/* - gl.useProgram(shaderProgram); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - // console.log(">>") - // - // alert(this.defaultShader.aPositionCoord) - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord); - gl.enableVertexAttribArray(this.defaultShader.aScale); - gl.enableVertexAttribArray(this.defaultShader.aRotation);*/ - }; @@ -111,13 +97,7 @@ gl.useProgram(this.primitiveShader.program); this.setAttribs(this.primitiveShader.attributes); - /* - gl.disableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.disableVertexAttribArray(this.defaultShader.colorAttribute); - gl.disableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.enableVertexAttribArray(this.primitiveShader.colorAttribute);*/ + }; PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() @@ -127,13 +107,20 @@ gl.useProgram(this.defaultShader.program); this.setAttribs(this.defaultShader.attributes); -/* - gl.disableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.disableVertexAttribArray(this.primitiveShader.colorAttribute); +}; - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); +PIXI.WebGLShaderManager.prototype.destroy = function(gl) +{ + this.attribState = null; + + this.tempAttribState = null; - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord);*/ -}; \ No newline at end of file + this.primitiveShader.destroy() + + this.defaultShader.destroy() + + this.fastShader.destroy() + + this.gl = null +}; + diff --git a/bin/pixi.dev.js b/bin/pixi.dev.js index 9dee4e4..17ab7cd 100644 --- a/bin/pixi.dev.js +++ b/bin/pixi.dev.js @@ -4,7 +4,7 @@ * Copyright (c) 2012, Mat Groves * http://goodboydigital.com/ * - * Compiled: 2014-01-23 + * Compiled: 2014-01-24 * * pixi.js is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license.php @@ -4384,6 +4384,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -4407,6 +4416,8 @@ + + /** * @author Mat Groves http://matgroves.com/ @Doormat23 * @author Richard Davey http://www.photonstorm.com @photonstorm @@ -4529,6 +4540,14 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 @@ -4666,6 +4685,16 @@ this.program = program; }; +PIXI.PrimitiveShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + + this.attribute = null +}; + /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5675,11 +5704,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; @@ -5751,6 +5785,12 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; + +PIXI.WebGLMaskManager.prototype.destroy = function() +{ + this.maskStack = null; + this.gl = null; +} /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ @@ -5784,22 +5824,8 @@ // this shader is used for the fast sprite rendering this.fastShader = new PIXI.PixiFastShader(gl); -// var shaderProgram = this.defaultShader.program; this.activateShader(this.defaultShader); -/* - gl.useProgram(shaderProgram); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - // console.log(">>") - // - // alert(this.defaultShader.aPositionCoord) - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord); - gl.enableVertexAttribArray(this.defaultShader.aScale); - gl.enableVertexAttribArray(this.defaultShader.aRotation);*/ - }; @@ -5864,13 +5890,7 @@ gl.useProgram(this.primitiveShader.program); this.setAttribs(this.primitiveShader.attributes); - /* - gl.disableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.disableVertexAttribArray(this.defaultShader.colorAttribute); - gl.disableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.enableVertexAttribArray(this.primitiveShader.colorAttribute);*/ + }; PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() @@ -5880,16 +5900,24 @@ gl.useProgram(this.defaultShader.program); this.setAttribs(this.defaultShader.attributes); -/* - gl.disableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.disableVertexAttribArray(this.primitiveShader.colorAttribute); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord);*/ }; + +PIXI.WebGLShaderManager.prototype.destroy = function(gl) +{ + this.attribState = null; + + this.tempAttribState = null; + + this.primitiveShader.destroy() + + this.defaultShader.destroy() + + this.fastShader.destroy() + + this.gl = null +}; + + /** * @author Mat Groves * @@ -6281,7 +6309,40 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +PIXI.WebGLSpriteBatch.prototype.destroy = function() +{ + this.vertices = null; + this.indices = null; + + this.gl.deleteBuffer( this.vertexBuffer ); + this.gl.deleteBuffer( this.indexBuffer ); + + this.currentBaseTexture = null; + + this.gl = null +}; + +PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) +{ + this.gl = gl; + + // create a couple of buffers + this.vertexBuffer = gl.createBuffer(); + this.indexBuffer = gl.createBuffer(); + + // 65535 is max index, so 65535 / 6 = 10922. + + + //upload the index data + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this.vertices, gl.DYNAMIC_DRAW); + + this.currentBlendMode = 99999; +} /** * @author Mat Groves diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index 325cdb9..0475ed5 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -465,11 +465,16 @@ this.offset = null; // time to create the render managers! each one focuses on managine a state in webGL - // this.shaderManager.destroy(); - // this.spriteBatch.destroy(); - // this.maskManager.destroy(); + this.shaderManager.destroy(); + this.spriteBatch.destroy(); + this.maskManager.destroy(); this.filterManager.destroy(); + this.shaderManager = null; + this.spriteBatch = null; + this.maskManager = null; + this.filterManager = null; + this.gl = null; // this.renderSession = null; diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index eb4c520..d516e11 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -120,3 +120,11 @@ this.program = program; }; +PIXI.PixiFastShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index cae7ae6..1ce8253 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -297,6 +297,15 @@ }; +PIXI.PixiShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + this.attributes = null +} + PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -319,3 +328,5 @@ ]; + + diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index ecb1880..d3df036 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -65,3 +65,13 @@ this.program = program; }; + +PIXI.PrimitiveShader.prototype.destroy = function() +{ + this.gl.deleteProgram( this.program ); + this.uniforms = null + this.gl = null; + + + this.attribute = null +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index 8e6f46c..0fc75fb 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -60,4 +60,10 @@ } if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); -}; \ No newline at end of file +}; + +PIXI.WebGLMaskManager.prototype.destroy = function() +{ + this.maskStack = null; + this.gl = null; +} \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js index 845504d..1984f04 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js @@ -31,22 +31,8 @@ // this shader is used for the fast sprite rendering this.fastShader = new PIXI.PixiFastShader(gl); -// var shaderProgram = this.defaultShader.program; this.activateShader(this.defaultShader); -/* - gl.useProgram(shaderProgram); - - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); - // console.log(">>") - // - // alert(this.defaultShader.aPositionCoord) - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord); - gl.enableVertexAttribArray(this.defaultShader.aScale); - gl.enableVertexAttribArray(this.defaultShader.aRotation);*/ - }; @@ -111,13 +97,7 @@ gl.useProgram(this.primitiveShader.program); this.setAttribs(this.primitiveShader.attributes); - /* - gl.disableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.disableVertexAttribArray(this.defaultShader.colorAttribute); - gl.disableVertexAttribArray(this.defaultShader.aTextureCoord); - - gl.enableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.enableVertexAttribArray(this.primitiveShader.colorAttribute);*/ + }; PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() @@ -127,13 +107,20 @@ gl.useProgram(this.defaultShader.program); this.setAttribs(this.defaultShader.attributes); -/* - gl.disableVertexAttribArray(this.primitiveShader.aVertexPosition); - gl.disableVertexAttribArray(this.primitiveShader.colorAttribute); +}; - gl.enableVertexAttribArray(this.defaultShader.aVertexPosition); - gl.enableVertexAttribArray(this.defaultShader.colorAttribute); - gl.enableVertexAttribArray(this.defaultShader.aTextureCoord); +PIXI.WebGLShaderManager.prototype.destroy = function(gl) +{ + this.attribState = null; + + this.tempAttribState = null; - gl.enableVertexAttribArray(this.defaultShader.aPositionCoord);*/ -}; \ No newline at end of file + this.primitiveShader.destroy() + + this.defaultShader.destroy() + + this.fastShader.destroy() + + this.gl = null +}; + diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index 7dd5b26..4652077 100644 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -389,4 +389,37 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +PIXI.WebGLSpriteBatch.prototype.destroy = function() +{ + this.vertices = null; + this.indices = null; + + this.gl.deleteBuffer( this.vertexBuffer ); + this.gl.deleteBuffer( this.indexBuffer ); + + this.currentBaseTexture = null; + + this.gl = null +}; + +PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) +{ + this.gl = gl; + + // create a couple of buffers + this.vertexBuffer = gl.createBuffer(); + this.indexBuffer = gl.createBuffer(); + + // 65535 is max index, so 65535 / 6 = 10922. + + + //upload the index data + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this.vertices, gl.DYNAMIC_DRAW); + + this.currentBlendMode = 99999; +}