File tree Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -1326,12 +1326,30 @@ p5.Shader = class {
1326
1326
}
1327
1327
break ;
1328
1328
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
+ if (
1331
+ data < gl . TEXTURE0 ||
1332
+ data > gl . TEXTURE31 ||
1333
+ data !== Math . ceil ( data )
1334
+ ) {
1335
+ console . log (
1336
+ '🌸 p5.js says: ' +
1337
+ 'You\'re trying to use a number as the data for a texture.' +
1338
+ 'Please use a texture.'
1339
+ ) ;
1340
+ return this ;
1341
+ }
1342
+ gl . activeTexture ( data ) ;
1343
+ gl . uniform1i ( location , data ) ;
1344
+ }
1345
+ else {
1346
+ gl . activeTexture ( gl . TEXTURE0 + uniform . samplerIndex ) ;
1347
+ uniform . texture =
1348
+ data instanceof p5 . Texture ? data : this . _renderer . getTexture ( data ) ;
1349
+ gl . uniform1i ( location , uniform . samplerIndex ) ;
1350
+ if ( uniform . texture . src . gifProperties ) {
1351
+ uniform . texture . src . _animateGif ( this . _renderer . _pInst ) ;
1352
+ }
1335
1353
}
1336
1354
break ;
1337
1355
//@todo complete all types
You can’t perform that action at this time.
0 commit comments