Hello @PianoMastR64,
When using PGraphics I have always had a setup frame first; I may have encountered this issue in the past and in the habit of doing this now.
This will get around that first frame behavior.
This code has the PG setup frame and will toggle between PGraphics renderers (P2D and JAVA2D):
PGraphics pg;
boolean toggle;
void setup()
{
size(800, 800, P2D);
if (toggle)
{
pg = createGraphics(width, height, JAVA2D);
println("PG P2D");
println("Renderer: " + g.getClass().getName());
println("Renderer: " + pg.getClass().getName());
}
else
{
pg = createGraphics(width, height, P2D);
//println("PG JAVA2D");
println("Renderer: " + g.getClass().getName());
println("Renderer: " + pg.getClass().getName());
}
//Setup frame workaround
pg.beginDraw();
//pg.clear();
pg.endDraw();
pg.beginDraw();
pg.noStroke();
//pg.clear();
pg.fill(255, 127);
pg.rect(0, 0, 195, height);
println(hex(pg.get(10, 10)));
pg.endDraw();
background(0);
image(pg, 0, 0);
}
void draw()
{
pg.beginDraw();
//pg.clear();
pg.fill(255, 127);
switch(frameCount) {
case 1 :
pg.rect(200, 0, 195, height);
println(hex(pg.get(210, 10)));
break;
case 2 :
pg.rect(400, 0, 195, height);
println(hex(pg.get(410, 10)));
break;
case 3 :
pg.rect(600, 0, 195, height);
println(hex(pg.get(610, 10)));
break;
}
pg.endDraw();
background(0);
image(pg, 0, 0);
}
void keyPressed()
{
toggle = !toggle;
frameCount = -1; // See https://discourse.processing.org/t/about-restarting/22557/3
}
That still leaves the color mixing issues/behavior mentioned previously.
Reference:
https://discourse.processing.org/t/about-restarting/22557/3
:)