diff --git a/src/core/display/DisplayObjectContainer.js b/src/core/display/DisplayObjectContainer.js index 7b0afd3..9b3a62f 100644 --- a/src/core/display/DisplayObjectContainer.js +++ b/src/core/display/DisplayObjectContainer.js @@ -456,9 +456,7 @@ } // add this object to the batch, only rendered if it has a texture. - if (this.texture) { - renderer.spriteBatch.render(this); - } + this._renderWebGL(renderer); // now loop through the children and make sure they get rendered for (i = 0, j = this.children.length; i < j; i++) { @@ -479,9 +477,8 @@ renderer.spriteBatch.start(); } else { - if (this.texture) { - renderer.spriteBatch.render(this); - } + + this._renderWebGL(renderer); // simple render children! for (i = 0, j = this.children.length; i < j; ++i) { @@ -491,6 +488,12 @@ } }; +DisplayObjectContainer.prototype._renderWebGL = function (renderer) { + + // this is where content itself gets renderd.. + +} + /** * Renders the object using the Canvas renderer * diff --git a/src/core/display/DisplayObjectContainer.js b/src/core/display/DisplayObjectContainer.js index 7b0afd3..9b3a62f 100644 --- a/src/core/display/DisplayObjectContainer.js +++ b/src/core/display/DisplayObjectContainer.js @@ -456,9 +456,7 @@ } // add this object to the batch, only rendered if it has a texture. - if (this.texture) { - renderer.spriteBatch.render(this); - } + this._renderWebGL(renderer); // now loop through the children and make sure they get rendered for (i = 0, j = this.children.length; i < j; i++) { @@ -479,9 +477,8 @@ renderer.spriteBatch.start(); } else { - if (this.texture) { - renderer.spriteBatch.render(this); - } + + this._renderWebGL(renderer); // simple render children! for (i = 0, j = this.children.length; i < j; ++i) { @@ -491,6 +488,12 @@ } }; +DisplayObjectContainer.prototype._renderWebGL = function (renderer) { + + // this is where content itself gets renderd.. + +} + /** * Renders the object using the Canvas renderer * diff --git a/src/core/display/Sprite.js b/src/core/display/Sprite.js index cba46f8..4978774 100644 --- a/src/core/display/Sprite.js +++ b/src/core/display/Sprite.js @@ -183,6 +183,13 @@ } }; +Sprite.prototype._renderWebGL = function (renderer) { + + // this is where content gets renderd.. + // watch this space for a little render state manager.. + renderer.spriteBatch.render(this); +} + /** * Returns the bounds of the Sprite as a rectangle. The bounds calculation takes the worldTransform into account. * diff --git a/src/core/display/DisplayObjectContainer.js b/src/core/display/DisplayObjectContainer.js index 7b0afd3..9b3a62f 100644 --- a/src/core/display/DisplayObjectContainer.js +++ b/src/core/display/DisplayObjectContainer.js @@ -456,9 +456,7 @@ } // add this object to the batch, only rendered if it has a texture. - if (this.texture) { - renderer.spriteBatch.render(this); - } + this._renderWebGL(renderer); // now loop through the children and make sure they get rendered for (i = 0, j = this.children.length; i < j; i++) { @@ -479,9 +477,8 @@ renderer.spriteBatch.start(); } else { - if (this.texture) { - renderer.spriteBatch.render(this); - } + + this._renderWebGL(renderer); // simple render children! for (i = 0, j = this.children.length; i < j; ++i) { @@ -491,6 +488,12 @@ } }; +DisplayObjectContainer.prototype._renderWebGL = function (renderer) { + + // this is where content itself gets renderd.. + +} + /** * Renders the object using the Canvas renderer * diff --git a/src/core/display/Sprite.js b/src/core/display/Sprite.js index cba46f8..4978774 100644 --- a/src/core/display/Sprite.js +++ b/src/core/display/Sprite.js @@ -183,6 +183,13 @@ } }; +Sprite.prototype._renderWebGL = function (renderer) { + + // this is where content gets renderd.. + // watch this space for a little render state manager.. + renderer.spriteBatch.render(this); +} + /** * Returns the bounds of the Sprite as a rectangle. The bounds calculation takes the worldTransform into account. * diff --git a/src/core/primitives/Graphics.js b/src/core/primitives/Graphics.js index 0a2ba1b..6ee7465 100644 --- a/src/core/primitives/Graphics.js +++ b/src/core/primitives/Graphics.js @@ -655,12 +655,15 @@ * * @param renderer {WebGLRenderer} */ -Graphics.prototype.renderWebGL = function (renderer) { +Graphics.prototype._renderWebGL = function (renderer) { // if the sprite is not visible or the alpha is 0 then no need to render this element - if (!this.visible || this.alpha <= 0 || this.isMask === true) { + if (this.isMask === true) { return; } + // this code may still be needed so leaving for now.. + // + /* if (this._cacheAsBitmap) { if (this.dirty || this.cachedSpriteDirty) { this._generateCachedSprite(); @@ -678,26 +681,13 @@ return; } - else { + else */ + renderer.spriteBatch.stop(); renderer.blendModeManager.setBlendMode(this.blendMode); - if (this._mask) { - renderer.maskManager.pushMask(this._mask, renderer); - } - - if (this._filters) { - renderer.filterManager.pushFilter(this._filterBlock); - } - // check blend mode - if (this.blendMode !== renderer.spriteBatch.currentBlendMode) { - renderer.spriteBatch.currentBlendMode = this.blendMode; - - var blendModeWebGL = renderer.blendModes[renderer.spriteBatch.currentBlendMode]; - - renderer.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); - } + renderer.blendModeManager.setBlendMode( this.blendMode ); // check if the webgl graphic needs to be updated if (this.glDirty) { @@ -707,30 +697,7 @@ WebGLGraphics.renderGraphics(this, renderer); - // only render if it has children! - if (this.children.length) { - renderer.spriteBatch.start(); - - // simple render children! - for (var i = 0, j = this.children.length; i < j; ++i) { - this.children[i].renderWebGL(renderer); - } - - renderer.spriteBatch.stop(); - } - - if (this._filters) { - renderer.filterManager.popFilter(); - } - - if (this._mask) { - renderer.maskManager.popMask(this.mask, renderer); - } - - renderer.drawCount++; - renderer.spriteBatch.start(); - } }; /** diff --git a/src/core/display/DisplayObjectContainer.js b/src/core/display/DisplayObjectContainer.js index 7b0afd3..9b3a62f 100644 --- a/src/core/display/DisplayObjectContainer.js +++ b/src/core/display/DisplayObjectContainer.js @@ -456,9 +456,7 @@ } // add this object to the batch, only rendered if it has a texture. - if (this.texture) { - renderer.spriteBatch.render(this); - } + this._renderWebGL(renderer); // now loop through the children and make sure they get rendered for (i = 0, j = this.children.length; i < j; i++) { @@ -479,9 +477,8 @@ renderer.spriteBatch.start(); } else { - if (this.texture) { - renderer.spriteBatch.render(this); - } + + this._renderWebGL(renderer); // simple render children! for (i = 0, j = this.children.length; i < j; ++i) { @@ -491,6 +488,12 @@ } }; +DisplayObjectContainer.prototype._renderWebGL = function (renderer) { + + // this is where content itself gets renderd.. + +} + /** * Renders the object using the Canvas renderer * diff --git a/src/core/display/Sprite.js b/src/core/display/Sprite.js index cba46f8..4978774 100644 --- a/src/core/display/Sprite.js +++ b/src/core/display/Sprite.js @@ -183,6 +183,13 @@ } }; +Sprite.prototype._renderWebGL = function (renderer) { + + // this is where content gets renderd.. + // watch this space for a little render state manager.. + renderer.spriteBatch.render(this); +} + /** * Returns the bounds of the Sprite as a rectangle. The bounds calculation takes the worldTransform into account. * diff --git a/src/core/primitives/Graphics.js b/src/core/primitives/Graphics.js index 0a2ba1b..6ee7465 100644 --- a/src/core/primitives/Graphics.js +++ b/src/core/primitives/Graphics.js @@ -655,12 +655,15 @@ * * @param renderer {WebGLRenderer} */ -Graphics.prototype.renderWebGL = function (renderer) { +Graphics.prototype._renderWebGL = function (renderer) { // if the sprite is not visible or the alpha is 0 then no need to render this element - if (!this.visible || this.alpha <= 0 || this.isMask === true) { + if (this.isMask === true) { return; } + // this code may still be needed so leaving for now.. + // + /* if (this._cacheAsBitmap) { if (this.dirty || this.cachedSpriteDirty) { this._generateCachedSprite(); @@ -678,26 +681,13 @@ return; } - else { + else */ + renderer.spriteBatch.stop(); renderer.blendModeManager.setBlendMode(this.blendMode); - if (this._mask) { - renderer.maskManager.pushMask(this._mask, renderer); - } - - if (this._filters) { - renderer.filterManager.pushFilter(this._filterBlock); - } - // check blend mode - if (this.blendMode !== renderer.spriteBatch.currentBlendMode) { - renderer.spriteBatch.currentBlendMode = this.blendMode; - - var blendModeWebGL = renderer.blendModes[renderer.spriteBatch.currentBlendMode]; - - renderer.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); - } + renderer.blendModeManager.setBlendMode( this.blendMode ); // check if the webgl graphic needs to be updated if (this.glDirty) { @@ -707,30 +697,7 @@ WebGLGraphics.renderGraphics(this, renderer); - // only render if it has children! - if (this.children.length) { - renderer.spriteBatch.start(); - - // simple render children! - for (var i = 0, j = this.children.length; i < j; ++i) { - this.children[i].renderWebGL(renderer); - } - - renderer.spriteBatch.stop(); - } - - if (this._filters) { - renderer.filterManager.popFilter(); - } - - if (this._mask) { - renderer.maskManager.popMask(this.mask, renderer); - } - - renderer.drawCount++; - renderer.spriteBatch.start(); - } }; /** diff --git a/src/core/renderers/webgl/managers/WebGLStencilManager.js b/src/core/renderers/webgl/managers/WebGLStencilManager.js index 43dbba1..9ec6398 100644 --- a/src/core/renderers/webgl/managers/WebGLStencilManager.js +++ b/src/core/renderers/webgl/managers/WebGLStencilManager.js @@ -119,21 +119,22 @@ this.renderer.shaderManager.setShader(shader); - gl.uniform1f(shader.flipY, this.renderer.flipY); + gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); - gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true)); + gl.uniform1f(shader.uniforms.flipY._location, 1); - gl.uniform2f(shader.projectionVector, projection.x, -projection.y); - gl.uniform2f(shader.offsetVector, -offset.x, -offset.y); + gl.uniform2f(shader.uniforms.projectionVector._location, projection.x, -projection.y); + gl.uniform2f(shader.uniforms.offsetVector._location, -offset.x, -offset.y); - gl.uniform3fv(shader.tintColor, utils.hex2rgb(graphics.tint)); - gl.uniform3fv(shader.color, webGLData.color); + gl.uniform3fv(shader.uniforms.tint._location, utils.hex2rgb(graphics.tint)); - gl.uniform1f(shader.alpha, graphics.worldAlpha * webGLData.alpha); + gl.uniform3fv(shader.uniforms.color._location, webGLData.color); + + gl.uniform1f(shader.uniforms.alpha._location, graphics.worldAlpha); gl.bindBuffer(gl.ARRAY_BUFFER, webGLData.buffer); - gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 4 * 2, 0); + gl.vertexAttribPointer(shader.attributes.aVertexPosition, 2, gl.FLOAT, false, 4 * 2, 0); // now do the rest.. @@ -145,20 +146,22 @@ shader = this.renderer.shaderManager.primitiveShader; this.renderer.shaderManager.setShader( shader ); - gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true)); + gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); - gl.uniform1f(shader.flipY, this.renderer.flipY); - gl.uniform2f(shader.projectionVector, projection.x, -projection.y); - gl.uniform2f(shader.offsetVector, -offset.x, -offset.y); + gl.uniform1f(shader.uniforms.flipY._location, 1); - gl.uniform3fv(shader.tintColor, utils.hex2rgb(graphics.tint)); + gl.uniform2f(shader.uniforms.projectionVector._location, projection.x, -projection.y); + gl.uniform2f(shader.uniforms.offsetVector._location, -offset.x, -offset.y); - gl.uniform1f(shader.alpha, graphics.worldAlpha); + gl.uniform3fv(shader.uniforms.tint._location, utils.hex2rgb(graphics.tint)); + + gl.uniform1f(shader.uniforms.alpha._location, graphics.worldAlpha); + gl.bindBuffer(gl.ARRAY_BUFFER, webGLData.buffer); - gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 4 * 6, 0); - gl.vertexAttribPointer(shader.aColor, 4, gl.FLOAT, false,4 * 6, 2 * 4); + gl.vertexAttribPointer(shader.attributes.aVertexPosition, 2, gl.FLOAT, false, 4 * 6, 0); + gl.vertexAttribPointer(shader.attributes.aColor, 4, gl.FLOAT, false,4 * 6, 2 * 4); // set the index buffer! gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, webGLData.indexBuffer); diff --git a/src/core/display/DisplayObjectContainer.js b/src/core/display/DisplayObjectContainer.js index 7b0afd3..9b3a62f 100644 --- a/src/core/display/DisplayObjectContainer.js +++ b/src/core/display/DisplayObjectContainer.js @@ -456,9 +456,7 @@ } // add this object to the batch, only rendered if it has a texture. - if (this.texture) { - renderer.spriteBatch.render(this); - } + this._renderWebGL(renderer); // now loop through the children and make sure they get rendered for (i = 0, j = this.children.length; i < j; i++) { @@ -479,9 +477,8 @@ renderer.spriteBatch.start(); } else { - if (this.texture) { - renderer.spriteBatch.render(this); - } + + this._renderWebGL(renderer); // simple render children! for (i = 0, j = this.children.length; i < j; ++i) { @@ -491,6 +488,12 @@ } }; +DisplayObjectContainer.prototype._renderWebGL = function (renderer) { + + // this is where content itself gets renderd.. + +} + /** * Renders the object using the Canvas renderer * diff --git a/src/core/display/Sprite.js b/src/core/display/Sprite.js index cba46f8..4978774 100644 --- a/src/core/display/Sprite.js +++ b/src/core/display/Sprite.js @@ -183,6 +183,13 @@ } }; +Sprite.prototype._renderWebGL = function (renderer) { + + // this is where content gets renderd.. + // watch this space for a little render state manager.. + renderer.spriteBatch.render(this); +} + /** * Returns the bounds of the Sprite as a rectangle. The bounds calculation takes the worldTransform into account. * diff --git a/src/core/primitives/Graphics.js b/src/core/primitives/Graphics.js index 0a2ba1b..6ee7465 100644 --- a/src/core/primitives/Graphics.js +++ b/src/core/primitives/Graphics.js @@ -655,12 +655,15 @@ * * @param renderer {WebGLRenderer} */ -Graphics.prototype.renderWebGL = function (renderer) { +Graphics.prototype._renderWebGL = function (renderer) { // if the sprite is not visible or the alpha is 0 then no need to render this element - if (!this.visible || this.alpha <= 0 || this.isMask === true) { + if (this.isMask === true) { return; } + // this code may still be needed so leaving for now.. + // + /* if (this._cacheAsBitmap) { if (this.dirty || this.cachedSpriteDirty) { this._generateCachedSprite(); @@ -678,26 +681,13 @@ return; } - else { + else */ + renderer.spriteBatch.stop(); renderer.blendModeManager.setBlendMode(this.blendMode); - if (this._mask) { - renderer.maskManager.pushMask(this._mask, renderer); - } - - if (this._filters) { - renderer.filterManager.pushFilter(this._filterBlock); - } - // check blend mode - if (this.blendMode !== renderer.spriteBatch.currentBlendMode) { - renderer.spriteBatch.currentBlendMode = this.blendMode; - - var blendModeWebGL = renderer.blendModes[renderer.spriteBatch.currentBlendMode]; - - renderer.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); - } + renderer.blendModeManager.setBlendMode( this.blendMode ); // check if the webgl graphic needs to be updated if (this.glDirty) { @@ -707,30 +697,7 @@ WebGLGraphics.renderGraphics(this, renderer); - // only render if it has children! - if (this.children.length) { - renderer.spriteBatch.start(); - - // simple render children! - for (var i = 0, j = this.children.length; i < j; ++i) { - this.children[i].renderWebGL(renderer); - } - - renderer.spriteBatch.stop(); - } - - if (this._filters) { - renderer.filterManager.popFilter(); - } - - if (this._mask) { - renderer.maskManager.popMask(this.mask, renderer); - } - - renderer.drawCount++; - renderer.spriteBatch.start(); - } }; /** diff --git a/src/core/renderers/webgl/managers/WebGLStencilManager.js b/src/core/renderers/webgl/managers/WebGLStencilManager.js index 43dbba1..9ec6398 100644 --- a/src/core/renderers/webgl/managers/WebGLStencilManager.js +++ b/src/core/renderers/webgl/managers/WebGLStencilManager.js @@ -119,21 +119,22 @@ this.renderer.shaderManager.setShader(shader); - gl.uniform1f(shader.flipY, this.renderer.flipY); + gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); - gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true)); + gl.uniform1f(shader.uniforms.flipY._location, 1); - gl.uniform2f(shader.projectionVector, projection.x, -projection.y); - gl.uniform2f(shader.offsetVector, -offset.x, -offset.y); + gl.uniform2f(shader.uniforms.projectionVector._location, projection.x, -projection.y); + gl.uniform2f(shader.uniforms.offsetVector._location, -offset.x, -offset.y); - gl.uniform3fv(shader.tintColor, utils.hex2rgb(graphics.tint)); - gl.uniform3fv(shader.color, webGLData.color); + gl.uniform3fv(shader.uniforms.tint._location, utils.hex2rgb(graphics.tint)); - gl.uniform1f(shader.alpha, graphics.worldAlpha * webGLData.alpha); + gl.uniform3fv(shader.uniforms.color._location, webGLData.color); + + gl.uniform1f(shader.uniforms.alpha._location, graphics.worldAlpha); gl.bindBuffer(gl.ARRAY_BUFFER, webGLData.buffer); - gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 4 * 2, 0); + gl.vertexAttribPointer(shader.attributes.aVertexPosition, 2, gl.FLOAT, false, 4 * 2, 0); // now do the rest.. @@ -145,20 +146,22 @@ shader = this.renderer.shaderManager.primitiveShader; this.renderer.shaderManager.setShader( shader ); - gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true)); + gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); - gl.uniform1f(shader.flipY, this.renderer.flipY); - gl.uniform2f(shader.projectionVector, projection.x, -projection.y); - gl.uniform2f(shader.offsetVector, -offset.x, -offset.y); + gl.uniform1f(shader.uniforms.flipY._location, 1); - gl.uniform3fv(shader.tintColor, utils.hex2rgb(graphics.tint)); + gl.uniform2f(shader.uniforms.projectionVector._location, projection.x, -projection.y); + gl.uniform2f(shader.uniforms.offsetVector._location, -offset.x, -offset.y); - gl.uniform1f(shader.alpha, graphics.worldAlpha); + gl.uniform3fv(shader.uniforms.tint._location, utils.hex2rgb(graphics.tint)); + + gl.uniform1f(shader.uniforms.alpha._location, graphics.worldAlpha); + gl.bindBuffer(gl.ARRAY_BUFFER, webGLData.buffer); - gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 4 * 6, 0); - gl.vertexAttribPointer(shader.aColor, 4, gl.FLOAT, false,4 * 6, 2 * 4); + gl.vertexAttribPointer(shader.attributes.aVertexPosition, 2, gl.FLOAT, false, 4 * 6, 0); + gl.vertexAttribPointer(shader.attributes.aColor, 4, gl.FLOAT, false,4 * 6, 2 * 4); // set the index buffer! gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, webGLData.indexBuffer); diff --git a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js index 35237c3..913ba5e 100644 --- a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -46,6 +46,7 @@ tint: { type: '3f', value: [0, 0, 0] }, flipY: { type: '1f', value: 0 }, alpha: { type: '1f', value: 0 }, + color: { type: '3f', value: [0,0,0] }, translationMatrix: { type: 'mat3', value: new Float32Array(9) } } ); diff --git a/src/core/display/DisplayObjectContainer.js b/src/core/display/DisplayObjectContainer.js index 7b0afd3..9b3a62f 100644 --- a/src/core/display/DisplayObjectContainer.js +++ b/src/core/display/DisplayObjectContainer.js @@ -456,9 +456,7 @@ } // add this object to the batch, only rendered if it has a texture. - if (this.texture) { - renderer.spriteBatch.render(this); - } + this._renderWebGL(renderer); // now loop through the children and make sure they get rendered for (i = 0, j = this.children.length; i < j; i++) { @@ -479,9 +477,8 @@ renderer.spriteBatch.start(); } else { - if (this.texture) { - renderer.spriteBatch.render(this); - } + + this._renderWebGL(renderer); // simple render children! for (i = 0, j = this.children.length; i < j; ++i) { @@ -491,6 +488,12 @@ } }; +DisplayObjectContainer.prototype._renderWebGL = function (renderer) { + + // this is where content itself gets renderd.. + +} + /** * Renders the object using the Canvas renderer * diff --git a/src/core/display/Sprite.js b/src/core/display/Sprite.js index cba46f8..4978774 100644 --- a/src/core/display/Sprite.js +++ b/src/core/display/Sprite.js @@ -183,6 +183,13 @@ } }; +Sprite.prototype._renderWebGL = function (renderer) { + + // this is where content gets renderd.. + // watch this space for a little render state manager.. + renderer.spriteBatch.render(this); +} + /** * Returns the bounds of the Sprite as a rectangle. The bounds calculation takes the worldTransform into account. * diff --git a/src/core/primitives/Graphics.js b/src/core/primitives/Graphics.js index 0a2ba1b..6ee7465 100644 --- a/src/core/primitives/Graphics.js +++ b/src/core/primitives/Graphics.js @@ -655,12 +655,15 @@ * * @param renderer {WebGLRenderer} */ -Graphics.prototype.renderWebGL = function (renderer) { +Graphics.prototype._renderWebGL = function (renderer) { // if the sprite is not visible or the alpha is 0 then no need to render this element - if (!this.visible || this.alpha <= 0 || this.isMask === true) { + if (this.isMask === true) { return; } + // this code may still be needed so leaving for now.. + // + /* if (this._cacheAsBitmap) { if (this.dirty || this.cachedSpriteDirty) { this._generateCachedSprite(); @@ -678,26 +681,13 @@ return; } - else { + else */ + renderer.spriteBatch.stop(); renderer.blendModeManager.setBlendMode(this.blendMode); - if (this._mask) { - renderer.maskManager.pushMask(this._mask, renderer); - } - - if (this._filters) { - renderer.filterManager.pushFilter(this._filterBlock); - } - // check blend mode - if (this.blendMode !== renderer.spriteBatch.currentBlendMode) { - renderer.spriteBatch.currentBlendMode = this.blendMode; - - var blendModeWebGL = renderer.blendModes[renderer.spriteBatch.currentBlendMode]; - - renderer.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); - } + renderer.blendModeManager.setBlendMode( this.blendMode ); // check if the webgl graphic needs to be updated if (this.glDirty) { @@ -707,30 +697,7 @@ WebGLGraphics.renderGraphics(this, renderer); - // only render if it has children! - if (this.children.length) { - renderer.spriteBatch.start(); - - // simple render children! - for (var i = 0, j = this.children.length; i < j; ++i) { - this.children[i].renderWebGL(renderer); - } - - renderer.spriteBatch.stop(); - } - - if (this._filters) { - renderer.filterManager.popFilter(); - } - - if (this._mask) { - renderer.maskManager.popMask(this.mask, renderer); - } - - renderer.drawCount++; - renderer.spriteBatch.start(); - } }; /** diff --git a/src/core/renderers/webgl/managers/WebGLStencilManager.js b/src/core/renderers/webgl/managers/WebGLStencilManager.js index 43dbba1..9ec6398 100644 --- a/src/core/renderers/webgl/managers/WebGLStencilManager.js +++ b/src/core/renderers/webgl/managers/WebGLStencilManager.js @@ -119,21 +119,22 @@ this.renderer.shaderManager.setShader(shader); - gl.uniform1f(shader.flipY, this.renderer.flipY); + gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); - gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true)); + gl.uniform1f(shader.uniforms.flipY._location, 1); - gl.uniform2f(shader.projectionVector, projection.x, -projection.y); - gl.uniform2f(shader.offsetVector, -offset.x, -offset.y); + gl.uniform2f(shader.uniforms.projectionVector._location, projection.x, -projection.y); + gl.uniform2f(shader.uniforms.offsetVector._location, -offset.x, -offset.y); - gl.uniform3fv(shader.tintColor, utils.hex2rgb(graphics.tint)); - gl.uniform3fv(shader.color, webGLData.color); + gl.uniform3fv(shader.uniforms.tint._location, utils.hex2rgb(graphics.tint)); - gl.uniform1f(shader.alpha, graphics.worldAlpha * webGLData.alpha); + gl.uniform3fv(shader.uniforms.color._location, webGLData.color); + + gl.uniform1f(shader.uniforms.alpha._location, graphics.worldAlpha); gl.bindBuffer(gl.ARRAY_BUFFER, webGLData.buffer); - gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 4 * 2, 0); + gl.vertexAttribPointer(shader.attributes.aVertexPosition, 2, gl.FLOAT, false, 4 * 2, 0); // now do the rest.. @@ -145,20 +146,22 @@ shader = this.renderer.shaderManager.primitiveShader; this.renderer.shaderManager.setShader( shader ); - gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true)); + gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); - gl.uniform1f(shader.flipY, this.renderer.flipY); - gl.uniform2f(shader.projectionVector, projection.x, -projection.y); - gl.uniform2f(shader.offsetVector, -offset.x, -offset.y); + gl.uniform1f(shader.uniforms.flipY._location, 1); - gl.uniform3fv(shader.tintColor, utils.hex2rgb(graphics.tint)); + gl.uniform2f(shader.uniforms.projectionVector._location, projection.x, -projection.y); + gl.uniform2f(shader.uniforms.offsetVector._location, -offset.x, -offset.y); - gl.uniform1f(shader.alpha, graphics.worldAlpha); + gl.uniform3fv(shader.uniforms.tint._location, utils.hex2rgb(graphics.tint)); + + gl.uniform1f(shader.uniforms.alpha._location, graphics.worldAlpha); + gl.bindBuffer(gl.ARRAY_BUFFER, webGLData.buffer); - gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 4 * 6, 0); - gl.vertexAttribPointer(shader.aColor, 4, gl.FLOAT, false,4 * 6, 2 * 4); + gl.vertexAttribPointer(shader.attributes.aVertexPosition, 2, gl.FLOAT, false, 4 * 6, 0); + gl.vertexAttribPointer(shader.attributes.aColor, 4, gl.FLOAT, false,4 * 6, 2 * 4); // set the index buffer! gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, webGLData.indexBuffer); diff --git a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js index 35237c3..913ba5e 100644 --- a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -46,6 +46,7 @@ tint: { type: '3f', value: [0, 0, 0] }, flipY: { type: '1f', value: 0 }, alpha: { type: '1f', value: 0 }, + color: { type: '3f', value: [0,0,0] }, translationMatrix: { type: 'mat3', value: new Float32Array(9) } } ); diff --git a/src/core/renderers/webgl/utils/WebGLGraphics.js b/src/core/renderers/webgl/utils/WebGLGraphics.js index 202c40d..55f4911 100644 --- a/src/core/renderers/webgl/utils/WebGLGraphics.js +++ b/src/core/renderers/webgl/utils/WebGLGraphics.js @@ -52,22 +52,22 @@ renderer.shaderManager.setShader( shader );//activatePrimitiveShader(); shader = renderer.shaderManager.primitiveShader; - gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true)); + gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location, false, graphics.worldTransform.toArray(true)); - gl.uniform1f(shader.flipY, 1); + gl.uniform1f(shader.uniforms.flipY._location, 1); - gl.uniform2f(shader.projectionVector, projection.x, -projection.y); - gl.uniform2f(shader.offsetVector, -offset.x, -offset.y); + gl.uniform2f(shader.uniforms.projectionVector._location, projection.x, -projection.y); + gl.uniform2f(shader.uniforms.offsetVector._location, -offset.x, -offset.y); - gl.uniform3fv(shader.tintColor, utils.hex2rgb(graphics.tint)); + gl.uniform3fv(shader.uniforms.tint._location, utils.hex2rgb(graphics.tint)); - gl.uniform1f(shader.alpha, graphics.worldAlpha); + gl.uniform1f(shader.uniforms.alpha._location, graphics.worldAlpha); gl.bindBuffer(gl.ARRAY_BUFFER, webGLData.buffer); - gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 4 * 6, 0); - gl.vertexAttribPointer(shader.aColor, 4, gl.FLOAT, false,4 * 6, 2 * 4); + gl.vertexAttribPointer(shader.attributes.aVertexPosition, 2, gl.FLOAT, false, 4 * 6, 0); + gl.vertexAttribPointer(shader.attributes.aColor, 4, gl.FLOAT, false,4 * 6, 2 * 4); // set the index buffer! gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, webGLData.indexBuffer);