Fix active texture binding.

If we don't change the active texture, we might bind a texture to the
wrong slot, and update the wrong texture.
This commit is contained in:
Ben Richards 2024-09-05 12:54:23 +12:00
parent 5ef3d45a50
commit 4bdede51f2

View file

@ -97,8 +97,7 @@ var WebGLTextureUnitsWrapper = new Class({
/**
* Binds a texture to a texture unit.
*
* If it was not already bound, or if `force` is true,
* this will change the active texture unit to the given unit.
* This will change the active texture unit to the given unit.
*
* This should be the only way to bind a texture to a unit.
*
@ -110,13 +109,13 @@ var WebGLTextureUnitsWrapper = new Class({
*/
bind: function (texture, unit, force)
{
if (this.units[unit] === texture && !force) { return; }
this.renderer.glWrapper.updateBindingsActiveTexture({
bindings:
{
activeTexture: unit
}
});
if (this.units[unit] === texture && !force) { return; }
this.units[unit] = texture;
var glTexture = texture ? texture.webGLTexture : null;
var gl = this.renderer.gl;