diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index 2357000..afdd03f 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -73,7 +73,7 @@ * @type Boolean */ this.preserveDrawingBuffer = options.preserveDrawingBuffer; - + /** * This sets if the WebGLRenderer will clear the context texture or not before the new render pass. If true: * If the Stage is NOT transparent, Pixi will clear to alpha (0, 0, 0, 0). @@ -85,7 +85,7 @@ * @default */ this.clearBeforeRender = options.clearBeforeRender; - + /** * The width of the canvas view * @@ -242,6 +242,8 @@ PIXI.glContexts[this.glContextId] = gl; + PIXI.instances[this.glContextId] = this; + // set up the default pixi settings.. gl.disable(gl.DEPTH_TEST); gl.disable(gl.CULL_FACE); @@ -286,7 +288,7 @@ stage.updateTransform(); var gl = this.gl; - + // interaction if(stage._interactive) { @@ -322,10 +324,10 @@ { gl.clearColor(stage.backgroundColorSplit[0],stage.backgroundColorSplit[1],stage.backgroundColorSplit[2], 1); } - + gl.clear (gl.COLOR_BUFFER_BIT); } - + this.renderDisplayObject( stage, this.projection ); }; @@ -340,7 +342,7 @@ PIXI.WebGLRenderer.prototype.renderDisplayObject = function(displayObject, projection, buffer) { this.renderSession.blendModeManager.setBlendMode(PIXI.blendModes.NORMAL); - + // reset the render session data.. this.renderSession.drawCount = 0; @@ -402,7 +404,7 @@ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === PIXI.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === PIXI.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); @@ -453,7 +455,7 @@ var texture = PIXI.TextureCache[key].baseTexture; texture._glTextures = []; } - + this.contextLost = false; }; @@ -522,3 +524,4 @@ }; PIXI.WebGLRenderer.glContextId = 0; +PIXI.WebGLRenderer.instances = []; diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index 2357000..afdd03f 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -73,7 +73,7 @@ * @type Boolean */ this.preserveDrawingBuffer = options.preserveDrawingBuffer; - + /** * This sets if the WebGLRenderer will clear the context texture or not before the new render pass. If true: * If the Stage is NOT transparent, Pixi will clear to alpha (0, 0, 0, 0). @@ -85,7 +85,7 @@ * @default */ this.clearBeforeRender = options.clearBeforeRender; - + /** * The width of the canvas view * @@ -242,6 +242,8 @@ PIXI.glContexts[this.glContextId] = gl; + PIXI.instances[this.glContextId] = this; + // set up the default pixi settings.. gl.disable(gl.DEPTH_TEST); gl.disable(gl.CULL_FACE); @@ -286,7 +288,7 @@ stage.updateTransform(); var gl = this.gl; - + // interaction if(stage._interactive) { @@ -322,10 +324,10 @@ { gl.clearColor(stage.backgroundColorSplit[0],stage.backgroundColorSplit[1],stage.backgroundColorSplit[2], 1); } - + gl.clear (gl.COLOR_BUFFER_BIT); } - + this.renderDisplayObject( stage, this.projection ); }; @@ -340,7 +342,7 @@ PIXI.WebGLRenderer.prototype.renderDisplayObject = function(displayObject, projection, buffer) { this.renderSession.blendModeManager.setBlendMode(PIXI.blendModes.NORMAL); - + // reset the render session data.. this.renderSession.drawCount = 0; @@ -402,7 +404,7 @@ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === PIXI.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === PIXI.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); @@ -453,7 +455,7 @@ var texture = PIXI.TextureCache[key].baseTexture; texture._glTextures = []; } - + this.contextLost = false; }; @@ -522,3 +524,4 @@ }; PIXI.WebGLRenderer.glContextId = 0; +PIXI.WebGLRenderer.instances = []; diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 725dce2..c787522 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -16,7 +16,7 @@ * @private */ this._UID = PIXI._UID++; - + /** * @property gl * @type WebGLContext @@ -82,7 +82,7 @@ /** * Initialises the shader. -* +* * @method init */ PIXI.PixiShader.prototype.init = function() @@ -90,7 +90,7 @@ var gl = this.gl; var program = PIXI.compileProgram(gl, this.vertexSrc || PIXI.PixiShader.defaultVertexSrc, this.fragmentSrc); - + gl.useProgram(program); // get and store the uniforms for the shader @@ -133,7 +133,7 @@ /** * Initialises the shader uniform values. -* +* * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * @@ -327,7 +327,7 @@ if(uniform.value.baseTexture._dirty[gl.id]) { - PIXI.defaultRenderer.updateTexture(uniform.value.baseTexture); + PIXI.WebGLRenderer.instances[gl.id].updateTexture(uniform.value.baseTexture); } else { @@ -350,7 +350,7 @@ /** * Destroys the shader. -* +* * @method destroy */ PIXI.PixiShader.prototype.destroy = function() @@ -364,7 +364,7 @@ /** * The Default Vertex shader source. -* +* * @property defaultVertexSrc * @type String */