We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I tried to add saveFrames in setup() of the official sample code here, but it seems to take no effect. May I ask if it's not supported to save frames for WEBGL renderer? I don't see it in reference document. Thanks!
Answers
Are you using the p5.js saveFrames(), here?
You said "it seems to take no effect." Which effect are you trying to create?
What is the callback that you are using? Can you share brief example code?
Hi Jeremy, yes I'm using saveFrames() without callback:
draw() is the same as original sample program. The png files I got all seem to be blank. Thanks.
Ah, I just noticed in your original post:
Setup runs first. It creates a canvas. Nothing has been drawn to the canvas.
You then run saveFrame in setup. Draw hasn't run yet. What will be in the frame? Nothing.
So you have to run saveFrame after draw has run at least once. You could run it at a particular time, or on a particular frame number, or in reaction to an event (e.g. keyPressed).
I added below to save on mouse click:
And I waited a while after all shapes started to rotate, before I clicked. Still I got an empty png.
Thanks again.
I just found a comment a while ago that it's not supported by default. I tried to change preserveDrawingBuffer in p5.js from false to true, it doesn't display correctly but does save to png file: