Fix new WebGLTextures remaining bound after creation.

This caused an error when calling `Shader.setRenderToTexture()`
after the game started running.
The leftover texture caused a temporary cyclic reference with the new
Framebuffer. The actual rendering pipeline was not affected.
This commit is contained in:
Ben Richards 2024-02-22 19:01:03 +13:00
parent e0f9e7d1d0
commit 3cd756dbe9
3 changed files with 11 additions and 1 deletions

View file

@ -6,6 +6,8 @@
# Bug Fixes
* Fix a single WebGL error, with no visual side-effects, from occurring while calling `Shader.setRenderToTexture()` after the game has started running. Actually, the root cause was leaving new WebGL textures bound after creation.
## Examples, Documentation, Beta Testing and TypeScript
Thanks to the following for helping with the Phaser Examples, Beta Testing, Docs, and TypeScript definitions, either by reporting errors, fixing them, or helping author the docs:

View file

@ -362,7 +362,7 @@ var Shader = new Class({
/**
* A reference to the Phaser.Textures.Texture that has been stored in the Texture Manager for this Shader.
*
* This property is only set if you have called `Shader.setRenderToTexture`, otherwise it is `null`.
* This property is only set if you have called `Shader.setRenderToTexture` with a key, otherwise it is `null`.
*
* @name Phaser.GameObjects.Shader#texture
* @type {Phaser.Textures.Texture}

View file

@ -302,6 +302,10 @@ var WebGLTextureWrapper = new Class({
{
gl.bindTexture(gl.TEXTURE_2D, currentTexture);
}
else
{
gl.bindTexture(gl.TEXTURE_2D, null);
}
// Assign the texture to our wrapper.
this.webGLTexture = texture;
@ -378,6 +382,10 @@ var WebGLTextureWrapper = new Class({
{
gl.bindTexture(gl.TEXTURE_2D, currentTexture);
}
else
{
gl.bindTexture(gl.TEXTURE_2D, null);
}
},
/**