Hi there.
I am using a PGraphics as a mask, the PGraphics’s background is set in the setup section so that my mask is not erased every frame.
Somehow that works fine with the default renderer, but not in P2D, there is no background.
I could of course initialize it in draw() only the first time, but does anyone know if there is a cleaner way to fix this?
PGraphics pg;
void setup(){
size(600, 400, P2D);
pg = createGraphics(width, height, P2D); // works with the default renderer, not in P2D
pg.beginDraw();
pg.background(0); // black background not showing in P2D PGraphics
pg.endDraw();
}
void draw(){
pg.beginDraw();
pg.fill(255);
pg.ellipse(mouseX, mouseY, 50, 50);
pg.endDraw();
image(pg, 0, 0);
}
What I mean is that instead of displaying a black background, it shows the default gray background, as if I had not set it up.
Nice idea for a workaround, but it doesn’t get me a black background either, still gray. It is like everything I draw on P2D PGraphics in setup is ignored.
I tested this and it works for me using either the default or P2D renderer.
Perhaps I should report this as a bug? Btw I have Processing 3.5.2
In Processing 3.4 I am seeing a black background with your test skech, as expected. So yes, this sounds like something that might be reported as an issue here: