Skip to content

Commit c14db00

Browse files
added ability to use setUniform for textures by texture slot rather than by p5.Texture
1 parent bf41e90 commit c14db00

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/webgl/p5.Shader.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,12 +1326,18 @@ p5.Shader = class {
13261326
}
13271327
break;
13281328
case gl.SAMPLER_2D:
1329-
gl.activeTexture(gl.TEXTURE0 + uniform.samplerIndex);
1330-
uniform.texture =
1331-
data instanceof p5.Texture ? data : this._renderer.getTexture(data);
1332-
gl.uniform1i(location, uniform.samplerIndex);
1333-
if (uniform.texture.src.gifProperties) {
1334-
uniform.texture.src._animateGif(this._renderer._pInst);
1329+
if (typeof data == 'number') {
1330+
gl.activeTexture(gl.TEXTURE0 + data);
1331+
gl.uniform1i(location, data);
1332+
}
1333+
else {
1334+
gl.activeTexture(gl.TEXTURE0 + uniform.samplerIndex);
1335+
uniform.texture =
1336+
data instanceof p5.Texture ? data : this._renderer.getTexture(data);
1337+
gl.uniform1i(location, uniform.samplerIndex);
1338+
if (uniform.texture.src.gifProperties) {
1339+
uniform.texture.src._animateGif(this._renderer._pInst);
1340+
}
13351341
}
13361342
break;
13371343
//@todo complete all types

0 commit comments

Comments
 (0)