Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dom/p5.MediaElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MediaElement extends Element {
source.src = newValue;
elt.appendChild(source);
self.elt.src = newValue;
self.modified = true;
self._modified = true;
}
});

Expand Down
3 changes: 3 additions & 0 deletions src/webgl/p5.Texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ class Texture {
data.setModified && data.setModified(true);
}
} else if (this.isSrcP5Image) {
if (data.gifProperties) {
data._animateGif(this._renderer._pInst);
}
// for an image, we only update if the modified field has been set,
// for example, by a call to p5.Image.set
if (data.isModified()) {
Expand Down
5 changes: 1 addition & 4 deletions src/webgl/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,14 @@ export function setWebGLUniformValue(shader, uniform, data, getTexture, gl) {
"You're trying to use a number as the data for a texture." +
"Please use a texture.",
);
return this;
return;
}
gl.activeTexture(data);
gl.uniform1i(location, data);
} else {
gl.activeTexture(gl.TEXTURE0 + uniform.samplerIndex);
uniform.texture = data instanceof Texture ? data : getTexture(data);
gl.uniform1i(location, uniform.samplerIndex);
if (uniform.texture.src.gifProperties) {
uniform.texture.src._animateGif(this._pInst);
}
}
break;
case gl.SAMPLER_CUBE:
Expand Down
21 changes: 21 additions & 0 deletions test/unit/visual/cases/webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1203,4 +1203,25 @@ visualSuite('WebGL', function() {
});
});

visualSuite('media assets', function() {
visualTest('drawing gifs', async function(p5, screenshot) {
p5.createCanvas(50, 50, p5.WEBGL);
const gif = await p5.loadImage('/test/unit/assets/nyan_cat.gif');
p5.imageMode(p5.CENTER);
p5.image(gif, 0, 0);
screenshot();
});

visualTest('drawing gifs after a time delay', async function(p5, screenshot) {
p5.createCanvas(50, 50, p5.WEBGL);
const gif = await p5.loadImage('/test/unit/assets/nyan_cat.gif');
p5.imageMode(p5.CENTER);
p5.image(gif, 0, 0);
p5.clear()
// Simulate waiting for successive draw calls
p5._lastRealFrameTime += 300;
p5.image(gif, 0, 0);
screenshot();
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading