PGraphics - read pixels as they are drawn

yea, i have already taken a bit of a look, as in PGraphics framebuffer can be rendered in `noLoop` mode but cannot be rendered in `loop` mode

however my main goal is obtaining the pixels of a PGraphics Object, like what

graphicsObject.endDraw();
image(graphicsObject);

does

geometry and other stuff such as lights are not particularly important, only the pixels that get drawn, now i CAN do this in noLoop mode (looping = false) however this seems broken, and i do not know why

note that i get

if i have

void drawBox() {
  // draw a box onto the PGraphics object
  g2.background(0);
  int c = wrap(frameCount, 255);
  g2.fill(0, c, c);
  if (frameCount == 1) g2.lights();
  g2.noStroke();
  //g2.translate(width/2, height/2);
  //g2.rotateX(frameCount/100.0);
  //g2.rotateY(frameCount/200.0);
  g2.box(40);
}

void draw() {
  if (!looping) looping = true;
  
  background(0);

  drawBox();
  
  // render the PGraphic's FBO, note this fails in loop mode
  g2.imageFrameBuffer();
  
  int oldColor = getGraphics().fillColor;
  fill(255);
  textSize(16);
  text("frameCount = " + frameCount + ", FPS: " + frameRate, 10, 20);
  fill(oldColor);
}

which indicates that all geometry and stuff gets reset somewhere in endDraw

note that


is used for g2.imageFrameBuffer();

in which if i do

  g2.beginDraw();
  drawBox();
  g2.endDraw();
  image(g2, 0, 0);

then lights gets reset in the next and subsequent draws