Skip to content

Commit 1711266

Browse files
committed
Fixed multi texture support on tiling sprite.
1 parent e15d98e commit 1711266

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

src/pixi/extras/TilingSprite.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
180180
{
181181
if (this.tilingTexture.needsUpdate)
182182
{
183+
this.tilingTexture.baseTexture.textureIndex = this.texture.baseTexture.textureIndex;
183184
renderSession.renderer.updateTexture(this.tilingTexture.baseTexture);
184185
this.tilingTexture.needsUpdate = false;
185186
}
@@ -197,7 +198,7 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
197198
this.children[i]._renderWebGL(renderSession);
198199
}
199200

200-
renderSession.spriteBatch.stop();
201+
//renderSession.spriteBatch.stop();
201202

202203
if (this._filters)
203204
{
@@ -209,7 +210,7 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
209210
renderSession.maskManager.popMask(this._mask, renderSession);
210211
}
211212

212-
renderSession.spriteBatch.start();
213+
//renderSession.spriteBatch.start();
213214

214215
};
215216

src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,12 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function (sprite) {
362362
var texture = sprite.tilingTexture;
363363
var baseTexture = texture.baseTexture;
364364
var gl = this.gl;
365-
366-
if (this.textureArray[baseTexture.textureIndex] != baseTexture) {
367-
gl.activeTexture(gl.TEXTURE0 + baseTexture.textureIndex);
368-
gl.bindTexture(gl.TEXTURE_2D, baseTexture._glTextures[gl.id]);
369-
this.textureArray[baseTexture.textureIndex] = baseTexture;
365+
var textureIndex = sprite.texture.baseTexture.textureIndex;
366+
if (this.textureArray[textureIndex] != baseTexture) {
370367
this.flush();
368+
gl.activeTexture(gl.TEXTURE0 + textureIndex);
369+
gl.bindTexture(gl.TEXTURE_2D, baseTexture._glTextures[gl.id]);
370+
this.textureArray[textureIndex] = baseTexture;
371371
}
372372

373373
// check texture..
@@ -444,7 +444,6 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function (sprite) {
444444
var d = wt.d / resolution;
445445
var tx = wt.tx;
446446
var ty = wt.ty;
447-
var textureIndex = texture.baseTexture.textureIndex;
448447
// xy
449448
positions[i++] = a * w1 + c * h1 + tx;
450449
positions[i++] = d * h1 + b * w1 + ty;
@@ -651,9 +650,6 @@ PIXI.WebGLSpriteBatch.prototype.renderBatch = function (texture, size, startInde
651650
// If updateTexture returns false then we cannot render it, so bail out now
652651
return;
653652
}
654-
} else {
655-
gl.activeTexture(gl.TEXTURE0 + texture.textureIndex);
656-
gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id]);
657653
}
658654
gl.drawElements(gl.TRIANGLES, size * 6, gl.UNSIGNED_SHORT, startIndex * 6 * 2);
659655
// increment the draw count

0 commit comments

Comments
 (0)