fix: background(image) support in WEBGL by reshma045 · Pull Request #8333 · processing/p5.js
Hi, thanks for making this PR! We can avoid explicitly checking the type of the renderer here by moving this code into the 3D renderer class instead. Because it calls _renderer.background(...), it will call the background method on whatever the active renderer is, so we can add specific code for WebGL in the WebGL renderer, and it already knows it's WebGL at that point.
In this case, I think that would mean moving your code into here:
| background(...args) { | |
| const _col = this._pInst.color(...args); | |
| this.clear(..._col._getRGBA()); | |
| } |
The one difference is that in the renderer, this is the renderer and not the p5 instance, so what is currently a call to this.push() for example would turn into this._pInst.push().