Merge branch 'dev-primitive' into dev

Conflicts:
	bin/pixi.js
This commit is contained in:
Mat Groves 2013-06-20 16:07:27 +01:00
commit 4b6d45c4a0
31 changed files with 7354 additions and 144 deletions

View file

@ -1499,7 +1499,7 @@ PIXI.InteractionManager.prototype.update = function()
var len = this.interactiveItems.length;
for (var i=0; i < this.interactiveItems.length; i++) {
for (var i=0; i < len; i++) {
this.interactiveItems[i].interactiveChildren = false;
}
@ -2484,6 +2484,11 @@ PIXI.shaderVertexSrc = [
"}"
];
/*
* primitive shader..
*/
PIXI.CompileVertexShader = function(gl, shaderSrc)
{
return PIXI._CompileShader(gl, shaderSrc, gl.VERTEX_SHADER);
@ -2509,6 +2514,35 @@ PIXI._CompileShader = function(gl, shaderSrc, shaderType)
return shader;
}
PIXI.activateDefaultShader = function()
{
var gl = PIXI.gl;
var shaderProgram = PIXI.shaderProgram;
gl.useProgram(shaderProgram);
gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute);
gl.enableVertexAttribArray(shaderProgram.textureCoordAttribute);
gl.enableVertexAttribArray(shaderProgram.colorAttribute);
}
PIXI.activatePrimitiveShader = function()
{
var gl = PIXI.gl;
gl.disableVertexAttribArray(PIXI.shaderProgram.textureCoordAttribute);
gl.disableVertexAttribArray(PIXI.shaderProgram.colorAttribute);
var shaderProgram2 = PIXI.shaderProgram2;
gl.useProgram(shaderProgram2);
gl.enableVertexAttribArray(shaderProgram2.vertexPositionAttribute);
gl.enableVertexAttribArray(PIXI.shaderProgram2.colorAttribute);
}
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -2567,9 +2601,9 @@ PIXI.WebGLRenderer = function(width, height, view, transparent)
throw new Error(" This browser does not support webGL. Try using the canvas renderer" + this);
}
PIXI.WebGLGraphics.initShaders();
this.initShaders();
var gl = this.gl;
PIXI.WebGLRenderer.gl = gl;
@ -2638,17 +2672,16 @@ PIXI.WebGLRenderer.prototype.initShaders = function()
gl.useProgram(shaderProgram);
shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition");
gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute);
shaderProgram.textureCoordAttribute = gl.getAttribLocation(shaderProgram, "aTextureCoord");
gl.enableVertexAttribArray(shaderProgram.textureCoordAttribute);
shaderProgram.colorAttribute = gl.getAttribLocation(shaderProgram, "aColor");
gl.enableVertexAttribArray(shaderProgram.colorAttribute);
shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, "uMVMatrix");
shaderProgram.samplerUniform = gl.getUniformLocation(shaderProgram, "uSampler");
PIXI.activateDefaultShader();
}
@ -2705,7 +2738,9 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
gl.clearColor(stage.backgroundColorSplit[0],stage.backgroundColorSplit[1],stage.backgroundColorSplit[2], !this.transparent);
gl.clear(gl.COLOR_BUFFER_BIT);
// HACK TO TEST
PIXI.projectionMatrix = this.projectionMatrix;
this.stageRenderGroup.backgroundColor = stage.backgroundColorSplit;
this.stageRenderGroup.render(this.projectionMatrix);
@ -3484,11 +3519,10 @@ PIXI.WebGLRenderGroup.prototype.setRenderable = function(displayObject)
PIXI.WebGLRenderGroup.prototype.render = function(projectionMatrix)
{
PIXI.WebGLRenderer.updateTextures();
var gl = this.gl;
// set the flipped matrix..
gl.uniformMatrix4fv(PIXI.shaderProgram.mvMatrixUniform, false, projectionMatrix);
@ -3514,6 +3548,10 @@ PIXI.WebGLRenderGroup.prototype.render = function(projectionMatrix)
{
if(renderable.visible)this.renderStrip(renderable, projectionMatrix);
}
else if(renderable instanceof PIXI.Graphics)
{
if(renderable.visible) PIXI.WebGLGraphics.renderGraphics(renderable);//, projectionMatrix);
}
}
}
@ -3846,19 +3884,16 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObject = function(displayObject)
var previousSprite = this.getPreviousRenderable(displayObject);
var nextSprite = this.getNextRenderable(displayObject);
/*
* so now we have the next renderable and the previous renderable
*
*/
if(displayObject instanceof PIXI.Sprite)
{
var previousBatch
var nextBatch
//console.log( previousSprite)
if(previousSprite instanceof PIXI.Sprite)
{
previousBatch = previousSprite.batch;
@ -3955,6 +3990,14 @@ PIXI.WebGLRenderGroup.prototype.addDisplayObject = function(displayObject)
this.initStrip(displayObject);
this.batchs.push(displayObject);
}
else if(displayObject instanceof PIXI.Graphics)
{
//displayObject.initWebGL(this);
// add to a batch!!
//this.initStrip(displayObject);
this.batchs.push(displayObject);
}
// if its somthing else... then custom codes!
this.batchUpdate = true;
@ -4546,6 +4589,10 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
{
displayObject.renderCanvas(this);
}
else if(displayObject instanceof PIXI.Graphics)
{
displayObject.render(this);
}
// render!
if(displayObject.children)