Trouble exporting P3D via PGraphics recording (OpenGL error 1282) [SOLVED?]

Something I often do to export higher resolution images is to instantiate a big PGraphics object and then use beginRecord, endRecord and add scaling to the offscreen canvas. It still works fine for 2D, but it seems like on the P3D renderer something broke (or maybe I got something wrong?). Can anyone please help me figure this out?

I get OpenGL error 1282 at top endDraw(): invalid operation is it a known issue?

UPDATE: It looks like the proper way is to use out.save(...) before endRecord() I think I never seen mention to it on the docs… well…

(The background is saved but not seen on screen which is a bit weird, and if you add a background call before the recording it has no effect… weirder still)


Note how the green background is missing, it draws fine without the export crash and exports fine on the standard renderer


int factor = 5;

void setup() {
  size(500, 500, P3D);
  PGraphics out = createGraphics(width * factor, height * factor, P3D);
  beginRecord(out);
  out.scale(factor);
  background(0, 100, 0);
  stroke(255);
  noFill();
  translate(250, 250, 0);
  box(200);
  endRecord();
  out.save("big_box.png");
}

PS: Could this be something that is more than 10 years old?