Skip to content

Commit f57b625

Browse files
instead of using texture slot # now uses WebGL constant and warns if a non-WebGL-constant number is used
1 parent c14db00 commit f57b625

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/webgl/p5.Shader.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,11 @@ p5.Shader = class {
13271327
break;
13281328
case gl.SAMPLER_2D:
13291329
if (typeof data == 'number') {
1330-
gl.activeTexture(gl.TEXTURE0 + data);
1330+
if (data < gl.TEXTURE0 && data > gl.TEXTURE31 && data === Math.ceil(data)) {
1331+
console.log('🌸 p5.js says: You\'re trying to use a number as the data for a texture. Please use a texture.');
1332+
return this;
1333+
}
1334+
gl.activeTexture(data);
13311335
gl.uniform1i(location, data);
13321336
}
13331337
else {

0 commit comments

Comments
 (0)