Fix filter() crash on createGraphics(WEBGL) by mirroring strands API …#8568
Fix filter() crash on createGraphics(WEBGL) by mirroring strands API …#8568aashu2006 wants to merge 2 commits intoprocessing:dev-2.0from
Conversation
…onto p5.Graphics.prototype
|
@ksen0, @davepagurek Thanks for taking a look! This implements the strands => |
davepagurek
left a comment
There was a problem hiding this comment.
Thanks for taking this on, it generally looks good! I left a comment on how we might be able to refactor a bit because currently it's handling graphicsOverrides a little differently than how it handles fn+fnOverrides and window+windowOverrides.
Then do you think we could also add some visual tests that create a WebGL graphic, run a strands shader on it, then draws the graphic back to the main canvas to take a screenshot? That way we can see if we've missed anything else that's required to get this to work.
|
Hi @davepagurek, I have addressed the review feedback:
Let me know if anything else should be adjusted, thanks! |
Resolves #8549
Changes
Fixes
filter()crash when called oncreateGraphics(WEBGL)buffers.Strands previously augmented only
p5.prototype, butp5.Graphicsdoes not inherit from it. Whenfilter()executed on ap5.Graphicsinstance, strands callbacks (e.g.getTexture,vec*,dot, etc.) were missing, causing runtime errors.This PR:
augmentFn(permanent, unconditional overwrite)augmentFnTemporary(temporary hook with restoration viagraphicsOverrides)p5.prototypeontop5.Graphics.prototypemodify()and restores them indeinitStrandsContextcreateGraphics(WEBGL).filter()has access to the full strands API layermodify()completesWebGL unit tests and visual tests pass locally. Manual testing confirms the crash is resolved.
Screenshots of the change:
Manual test confirming no crash and correct behavior:
createGraphics(WEBGL).filter(INVERT)runs without errorPR Checklist
npm run lintpasses