Skip to content

Commit 3fce918

Browse files
authored
Merge branch 'dev-2.0' into dependencies-update
2 parents b212b28 + 8b74c3f commit 3fce918

8 files changed

Lines changed: 32 additions & 5 deletions

File tree

src/dom/p5.MediaElement.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class MediaElement extends Element {
6666
source.src = newValue;
6767
elt.appendChild(source);
6868
self.elt.src = newValue;
69-
self.modified = true;
69+
self._modified = true;
7070
}
7171
});
7272

src/webgl/p5.Texture.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ class Texture {
225225
data.setModified && data.setModified(true);
226226
}
227227
} else if (this.isSrcP5Image) {
228+
if (data.gifProperties) {
229+
data._animateGif(this._renderer._pInst);
230+
}
228231
// for an image, we only update if the modified field has been set,
229232
// for example, by a call to p5.Image.set
230233
if (data.isModified()) {

src/webgl/utils.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,14 @@ export function setWebGLUniformValue(shader, uniform, data, getTexture, gl) {
281281
"You're trying to use a number as the data for a texture." +
282282
"Please use a texture.",
283283
);
284-
return this;
284+
return;
285285
}
286286
gl.activeTexture(data);
287287
gl.uniform1i(location, data);
288288
} else {
289289
gl.activeTexture(gl.TEXTURE0 + uniform.samplerIndex);
290290
uniform.texture = data instanceof Texture ? data : getTexture(data);
291291
gl.uniform1i(location, uniform.samplerIndex);
292-
if (uniform.texture.src.gifProperties) {
293-
uniform.texture.src._animateGif(this._pInst);
294-
}
295292
}
296293
break;
297294
case gl.SAMPLER_CUBE:

test/unit/visual/cases/webgl.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,4 +1203,25 @@ visualSuite('WebGL', function() {
12031203
});
12041204
});
12051205

1206+
visualSuite('media assets', function() {
1207+
visualTest('drawing gifs', async function(p5, screenshot) {
1208+
p5.createCanvas(50, 50, p5.WEBGL);
1209+
const gif = await p5.loadImage('/test/unit/assets/nyan_cat.gif');
1210+
p5.imageMode(p5.CENTER);
1211+
p5.image(gif, 0, 0);
1212+
screenshot();
1213+
});
1214+
1215+
visualTest('drawing gifs after a time delay', async function(p5, screenshot) {
1216+
p5.createCanvas(50, 50, p5.WEBGL);
1217+
const gif = await p5.loadImage('/test/unit/assets/nyan_cat.gif');
1218+
p5.imageMode(p5.CENTER);
1219+
p5.image(gif, 0, 0);
1220+
p5.clear()
1221+
// Simulate waiting for successive draw calls
1222+
p5._lastRealFrameTime += 300;
1223+
p5.image(gif, 0, 0);
1224+
screenshot();
1225+
});
1226+
});
12061227
});
805 Bytes
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
828 Bytes
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}

0 commit comments

Comments
 (0)