Text added to PIXI

destroy function added to textures too
docs updated
new example added
This commit is contained in:
Mat Groves 2013-04-24 20:54:03 +01:00
parent 7933cadb77
commit 09dbbd5d13
66 changed files with 10970 additions and 681 deletions

View file

@ -67,6 +67,8 @@
<li><a href="..&#x2F;classes/Stage.html">Stage</a></li>
<li><a href="..&#x2F;classes/Text.html">Text</a></li>
<li><a href="..&#x2F;classes/Texture.html">Texture</a></li>
<li><a href="..&#x2F;classes/TilingSprite.html">TilingSprite</a></li>
@ -142,6 +144,8 @@ PIXI._defaultFrame = new PIXI.Rectangle(0,0,1,1);
*&#x2F;
PIXI.WebGLRenderer = function(width, height, view, transparent)
{
&#x2F;&#x2F; do a catch.. only 1 webGL renderer..
&#x2F;&#x2F;console.log(transparent)
this.transparent = !!transparent;
@ -190,6 +194,31 @@ PIXI.WebGLRenderer = function(width, height, view, transparent)
&#x2F;&#x2F; constructor
PIXI.WebGLRenderer.constructor = PIXI.WebGLRenderer;
&#x2F;**
* @private
*&#x2F;
PIXI.WebGLRenderer.prototype.getBatch = function()
{
if(PIXI._batchs.length == 0)
{
return new PIXI.WebGLBatch(this.gl);
}
else
{
return PIXI._batchs.pop();
}
}
&#x2F;**
* @private
*&#x2F;
PIXI.WebGLRenderer.prototype.returnBatch = function(batch)
{
batch.clean();
PIXI._batchs.push(batch);
}
&#x2F;**
* @private
*&#x2F;
@ -307,12 +336,13 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
&#x2F;&#x2F; update any textures
for (var i=0; i &lt; PIXI.texturesToUpdate.length; i++) this.updateTexture(PIXI.texturesToUpdate[i]);
for (var i=0; i &lt; PIXI.texturesToDestroy.length; i++) this.destroyTexture(PIXI.texturesToDestroy[i]);
&#x2F;&#x2F; empty out the arrays
stage.__childrenRemoved = [];
stage.__childrenAdded = [];
PIXI.texturesToUpdate = [];
PIXI.texturesToDestroy = [];
&#x2F;&#x2F; recursivly loop through all items!
this.checkVisibility(stage, true);
@ -362,6 +392,17 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
stage.interactionManager.setTarget(this);
}
}
&#x2F;&#x2F; after rendering lets confirm all frames that have been uodated..
if(PIXI.Texture.frameUpdates.length &gt; 0)
{
for (var i=0; i &lt; PIXI.Texture.frameUpdates.length; i++)
{
PIXI.Texture.frameUpdates[i].updateFrame = false;
};
PIXI.Texture.frameUpdates = [];
}
}
&#x2F;**
@ -406,12 +447,23 @@ PIXI.WebGLRenderer.prototype.updateTexture = function(texture)
this.refreshBatchs = true;
}
PIXI.WebGLRenderer.prototype.destroyTexture = function(texture)
{
var gl = this.gl;
if(texture._glTexture)
{
texture._glTexture = gl.createTexture();
gl.deleteTexture(gl.TEXTURE_2D, texture._glTexture);
}
}
&#x2F;**
* @private
*&#x2F;
PIXI.WebGLRenderer.prototype.addDisplayObject = function(displayObject)
{
var objectDetaildisplayObject
if(!displayObject.stage)return; &#x2F;&#x2F; means it was removed
if(displayObject.__inWebGL)return; &#x2F;&#x2F;means it is already in webgL
@ -552,7 +604,7 @@ PIXI.WebGLRenderer.prototype.addDisplayObject = function(displayObject)
* seems the new sprite is in the middle of a batch
* lets split it..
*&#x2F;
var batch = PIXI._getBatch(this.gl);
var batch = this.getBatch();
var index = this.batchs.indexOf( previousBatch );
batch.init(displayObject);
@ -576,7 +628,7 @@ PIXI.WebGLRenderer.prototype.addDisplayObject = function(displayObject)
* time to create anew one!
*&#x2F;
var batch = PIXI._getBatch(this.gl);
var batch = this.getBatch();
batch.init(displayObject);
if(previousBatch) &#x2F;&#x2F; if this is invalid it means
@ -635,7 +687,6 @@ PIXI.WebGLRenderer.prototype.removeDisplayObject = function(displayObject)
batch.remove(displayObject);
if(batch.size==0)
{
batchToRemove = batch
@ -660,7 +711,7 @@ PIXI.WebGLRenderer.prototype.removeDisplayObject = function(displayObject)
{
&#x2F;&#x2F; wha - eva! just get of the empty batch!
this.batchs.splice(index, 1);
if(batchToRemove instanceof PIXI.WebGLBatch)PIXI._returnBatch(batchToRemove);
if(batchToRemove instanceof PIXI.WebGLBatch)this.returnBatch(batchToRemove);
return;
}
@ -672,8 +723,8 @@ PIXI.WebGLRenderer.prototype.removeDisplayObject = function(displayObject)
&#x2F;&#x2F;console.log(&quot;MERGE&quot;)
this.batchs[index-1].merge(this.batchs[index+1]);
if(batchToRemove instanceof PIXI.WebGLBatch)PIXI._returnBatch(batchToRemove);
PIXI._returnBatch(this.batchs[index+1]);
if(batchToRemove instanceof PIXI.WebGLBatch)this.returnBatch(batchToRemove);
this.returnBatch(this.batchs[index+1]);
this.batchs.splice(index, 2);
return;
}
@ -681,7 +732,7 @@ PIXI.WebGLRenderer.prototype.removeDisplayObject = function(displayObject)
this.batchs.splice(index, 1);
if(batchToRemove instanceof PIXI.WebGLBatch)PIXI._returnBatch(batchToRemove);
if(batchToRemove instanceof PIXI.WebGLBatch)this.returnBatch(batchToRemove);
}