RenderTexture update
RenderTexture added (webGL and Canvas) WebGL Render rearchitected - a little faster :) Pivot added to DisplayObject docs updated grunt file updated
This commit is contained in:
parent
ba5a79c606
commit
88b863155a
82 changed files with 14133 additions and 6332 deletions
|
@ -67,6 +67,8 @@
|
|||
|
||||
<li><a href="../classes/Rectangle.html">Rectangle</a></li>
|
||||
|
||||
<li><a href="../classes/RenderTexture.html">RenderTexture</a></li>
|
||||
|
||||
<li><a href="../classes/Sprite.html">Sprite</a></li>
|
||||
|
||||
<li><a href="../classes/SpriteSheetLoader.html">SpriteSheetLoader</a></li>
|
||||
|
@ -544,73 +546,95 @@ PIXI.WebGLBatch.prototype.update = function()
|
|||
|
||||
while(displayObject)
|
||||
{
|
||||
width = displayObject.texture.frame.width;
|
||||
height = displayObject.texture.frame.height;
|
||||
|
||||
aX = displayObject.anchor.x - displayObject.texture.trim.x
|
||||
aY = displayObject.anchor.y - displayObject.texture.trim.y
|
||||
w0 = width * (1-aX);
|
||||
w1 = width * -aX;
|
||||
|
||||
h0 = height * (1-aY);
|
||||
h1 = height * -aY;
|
||||
|
||||
index = indexRun * 8;
|
||||
|
||||
worldTransform = displayObject.worldTransform;
|
||||
if(displayObject.worldVisible)
|
||||
{
|
||||
width = displayObject.texture.frame.width;
|
||||
height = displayObject.texture.frame.height;
|
||||
|
||||
// TODO trim??
|
||||
aX = displayObject.anchor.x;// - displayObject.texture.trim.x
|
||||
aY = displayObject.anchor.y; //- displayObject.texture.trim.y
|
||||
w0 = width * (1-aX);
|
||||
w1 = width * -aX;
|
||||
|
||||
h0 = height * (1-aY);
|
||||
h1 = height * -aY;
|
||||
|
||||
index = indexRun * 8;
|
||||
|
||||
a = worldTransform[0];
|
||||
b = worldTransform[3];
|
||||
c = worldTransform[1];
|
||||
d = worldTransform[4];
|
||||
tx = worldTransform[2];
|
||||
ty = worldTransform[5];
|
||||
worldTransform = displayObject.worldTransform;
|
||||
|
||||
this.verticies[index + 0 ] = a * w1 + c * h1 + tx;
|
||||
this.verticies[index + 1 ] = d * h1 + b * w1 + ty;
|
||||
|
||||
this.verticies[index + 2 ] = a * w0 + c * h1 + tx;
|
||||
this.verticies[index + 3 ] = d * h1 + b * w0 + ty;
|
||||
a = worldTransform[0];
|
||||
b = worldTransform[3];
|
||||
c = worldTransform[1];
|
||||
d = worldTransform[4];
|
||||
tx = worldTransform[2];
|
||||
ty = worldTransform[5];
|
||||
|
||||
this.verticies[index + 4 ] = a * w0 + c * h0 + tx;
|
||||
this.verticies[index + 5 ] = d * h0 + b * w0 + ty;
|
||||
|
||||
this.verticies[index + 6] = a * w1 + c * h0 + tx;
|
||||
this.verticies[index + 7] = d * h0 + b * w1 + ty;
|
||||
|
||||
if(displayObject.updateFrame || displayObject.texture.updateFrame)
|
||||
{
|
||||
this.dirtyUVS = true;
|
||||
this.verticies[index + 0 ] = a * w1 + c * h1 + tx;
|
||||
this.verticies[index + 1 ] = d * h1 + b * w1 + ty;
|
||||
|
||||
this.verticies[index + 2 ] = a * w0 + c * h1 + tx;
|
||||
this.verticies[index + 3 ] = d * h1 + b * w0 + ty;
|
||||
|
||||
var texture = displayObject.texture;
|
||||
this.verticies[index + 4 ] = a * w0 + c * h0 + tx;
|
||||
this.verticies[index + 5 ] = d * h0 + b * w0 + ty;
|
||||
|
||||
var frame = texture.frame;
|
||||
var tw = texture.baseTexture.width;
|
||||
var th = texture.baseTexture.height;
|
||||
this.verticies[index + 6] = a * w1 + c * h0 + tx;
|
||||
this.verticies[index + 7] = d * h0 + b * w1 + ty;
|
||||
|
||||
this.uvs[index + 0] = frame.x / tw;
|
||||
this.uvs[index +1] = frame.y / th;
|
||||
|
||||
this.uvs[index +2] = (frame.x + frame.width) / tw;
|
||||
this.uvs[index +3] = frame.y / th;
|
||||
if(displayObject.updateFrame || displayObject.texture.updateFrame)
|
||||
{
|
||||
this.dirtyUVS = true;
|
||||
|
||||
var texture = displayObject.texture;
|
||||
|
||||
var frame = texture.frame;
|
||||
var tw = texture.baseTexture.width;
|
||||
var th = texture.baseTexture.height;
|
||||
|
||||
this.uvs[index + 0] = frame.x / tw;
|
||||
this.uvs[index +1] = frame.y / th;
|
||||
|
||||
this.uvs[index +2] = (frame.x + frame.width) / tw;
|
||||
this.uvs[index +3] = frame.y / th;
|
||||
|
||||
this.uvs[index +4] = (frame.x + frame.width) / tw;
|
||||
this.uvs[index +5] = (frame.y + frame.height) / th;
|
||||
|
||||
this.uvs[index +6] = frame.x / tw;
|
||||
this.uvs[index +7] = (frame.y + frame.height) / th;
|
||||
|
||||
displayObject.updateFrame = false;
|
||||
}
|
||||
|
||||
this.uvs[index +4] = (frame.x + frame.width) / tw;
|
||||
this.uvs[index +5] = (frame.y + frame.height) / th;
|
||||
|
||||
this.uvs[index +6] = frame.x / tw;
|
||||
this.uvs[index +7] = (frame.y + frame.height) / th;
|
||||
|
||||
displayObject.updateFrame = false;
|
||||
// TODO this probably could do with some optimisation....
|
||||
if(displayObject.cacheAlpha != displayObject.worldAlpha)
|
||||
{
|
||||
displayObject.cacheAlpha = displayObject.worldAlpha;
|
||||
|
||||
var colorIndex = indexRun * 4;
|
||||
this.colors[colorIndex] = this.colors[colorIndex + 1] = this.colors[colorIndex + 2] = this.colors[colorIndex + 3] = displayObject.worldAlpha;
|
||||
this.dirtyColors = true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO this probably could do with some optimisation....
|
||||
if(displayObject.cacheAlpha != displayObject.worldAlpha)
|
||||
else
|
||||
{
|
||||
displayObject.cacheAlpha = displayObject.worldAlpha;
|
||||
index = indexRun * 8;
|
||||
|
||||
var colorIndex = indexRun * 4;
|
||||
this.colors[colorIndex] = this.colors[colorIndex + 1] = this.colors[colorIndex + 2] = this.colors[colorIndex + 3] = displayObject.worldAlpha;
|
||||
this.dirtyColors = true;
|
||||
this.verticies[index + 0 ] = 0;
|
||||
this.verticies[index + 1 ] = 0;
|
||||
|
||||
this.verticies[index + 2 ] = 0;
|
||||
this.verticies[index + 3 ] = 0;
|
||||
|
||||
this.verticies[index + 4 ] = 0;
|
||||
this.verticies[index + 5 ] = 0;
|
||||
|
||||
this.verticies[index + 6] = 0;
|
||||
this.verticies[index + 7] = 0;
|
||||
}
|
||||
|
||||
indexRun++;
|
||||
|
@ -622,8 +646,13 @@ PIXI.WebGLBatch.prototype.update = function()
|
|||
* Draws the batch to the frame buffer
|
||||
* @method render
|
||||
*/
|
||||
PIXI.WebGLBatch.prototype.render = function()
|
||||
PIXI.WebGLBatch.prototype.render = function(start, end)
|
||||
{
|
||||
// console.log(start + " :: " + end + " : " + this.size);
|
||||
start = start || 0;
|
||||
//end = end || this.size;
|
||||
if(end == undefined)end = this.size;
|
||||
|
||||
if(this.dirty)
|
||||
{
|
||||
this.refresh();
|
||||
|
@ -636,16 +665,10 @@ PIXI.WebGLBatch.prototype.render = function()
|
|||
var gl = this.gl;
|
||||
|
||||
//TODO optimize this!
|
||||
if(this.blendMode == PIXI.blendModes.NORMAL)
|
||||
{
|
||||
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
else
|
||||
{
|
||||
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_COLOR);
|
||||
}
|
||||
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
var shaderProgram = PIXI.shaderProgram;
|
||||
gl.useProgram(shaderProgram);
|
||||
|
||||
// update the verts..
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
|
||||
|
@ -680,9 +703,13 @@ PIXI.WebGLBatch.prototype.render = function()
|
|||
|
||||
// dont need to upload!
|
||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
||||
|
||||
|
||||
|
||||
//var startIndex = 0//1;
|
||||
var len = end - start;
|
||||
// console.log(this.size)
|
||||
// DRAW THAT this!
|
||||
gl.drawElements(gl.TRIANGLES, this.size * 6, gl.UNSIGNED_SHORT, 0);
|
||||
gl.drawElements(gl.TRIANGLES, len * 6, gl.UNSIGNED_SHORT, start * 2 * 6 );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue