-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement load/updatePixels() and get() for framebuffers #6109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, thanks for putting this together @davepagurek . I left a couple notes on the PR.
One more thing that comes to mind is to check that if multiple fbo's are in the same sketch that calling loadPixels and updatePixels in arbitrary order still works as expected. For ex:
fbo1.loadPixels();
fbo2.loadPixels();
fbo2.updatePixels();
fbo1.updatePixels();
Another circumstance I wonder if we can catch is when someone tries to manipulate the pixel arrays or call updatePixels before loadPixels has been called. Perhaps a warning in those cases could help solve some programmer error.
Resolves #6082
This branches off of #5981 (since it also fixes WebGL pixels[] being inverted in the y axis), so we should review/merge that first.
Changes
loadPixels
/pixels
/updatePixels
/get
forp5.Framebuffer
get()
forp5.Graphics
, the resultingp5.Image
will always have a pixel density of 1 even if the source content has higher densityupdatePixels
for WebGL main canvases or graphicsp5.Texture
would be a tad cheaper, so we could switch to that eventually if we want, but I suspect we'll want to use a framebuffer in the future forfilter()
. Happy to discuss though!Screenshots of the change
Some example code drawing in 3D, updating pixels, then drawing some more: (Live version)
Some similar code using a framebuffer (used as an example for the docs of framebuffer's updatePixels): (Live version)
PR Checklist
npm run lint
passes