Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

- Fixed an error when the WebGL context of a destroyed game was lost (#756).
- Fixed a new WebGL renderer taking the context id of a live renderer after another renderer was destroyed (#757).
- Fixed multi-texture batching binding the last batched texture to whichever texture unit was active, which could draw the wrong texture (e.g., stretched over the canvas by the debug sprite) (#231).

### Thanks

Expand Down
6 changes: 6 additions & 0 deletions src/gameobjects/Creature.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ Phaser.Creature.prototype._renderCreature = function (renderSession)
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW);
}

if (PIXI._enableMultiTextureToggle)
{
PIXI.WebGLRenderer.textureArray[0] = null;
PIXI.WebGLRenderer.textureArray[this.texture.baseTexture.textureIndex] = null;
}

gl.drawElements(gl.TRIANGLES, this.indices.length, gl.UNSIGNED_SHORT, 0);
};

Expand Down
6 changes: 6 additions & 0 deletions src/gameobjects/Rope.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,12 @@ Phaser.Rope.prototype._renderStrip = function (renderSession)
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW);
}

if (PIXI._enableMultiTextureToggle)
{
PIXI.WebGLRenderer.textureArray[0] = null;
PIXI.WebGLRenderer.textureArray[this.texture.baseTexture.textureIndex] = null;
}

gl.drawElements(drawMode, this.indices.length, gl.UNSIGNED_SHORT, 0);
};

Expand Down
4 changes: 4 additions & 0 deletions src/pixi/renderers/webgl/utils/WebGLFilterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ PIXI.WebGLFilterManager.prototype.pushFilter = function (filterBlock)
this.offsetX += filterBlock._filterArea.x;
this.offsetY += filterBlock._filterArea.y;

gl.activeTexture(gl.TEXTURE0);

var texture = this.texturePool.pop();
if(!texture)
{
Expand All @@ -104,6 +106,7 @@ PIXI.WebGLFilterManager.prototype.pushFilter = function (filterBlock)
}

gl.bindTexture(gl.TEXTURE_2D, texture.texture);
PIXI.WebGLRenderer.textureArray[0] = null;

var filterArea = filterBlock._filterArea;// filterBlock.target.getBounds();///filterBlock.target.filterArea;

Expand Down Expand Up @@ -315,6 +318,7 @@ PIXI.WebGLFilterManager.prototype.popFilter = function ()
// set texture
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, texture.texture);
PIXI.WebGLRenderer.textureArray[0] = null;
Comment thread
Copilot marked this conversation as resolved.
Resolved

// >>> modify by nextht
if (this.renderSession.stencilManager)
Expand Down
3 changes: 2 additions & 1 deletion src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,9 @@ PIXI.WebGLSpriteBatch.prototype.renderBatch = function (texture, size, startInde
return;
}
}
else
else if (!PIXI._enableMultiTextureToggle)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalidated unit 0's cached texture binding after popFilter() binds the filter output. Commit: c05a0ad4e.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalidated unit 0 and the texture’s assigned unit after Rope and Creature render their direct bindings. Commit: d9301bcd1.

{
// With multi-texture batching each texture is already bound to its own unit
gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id]);
}

Expand Down
Loading