An example of using runSketch() in the PDE in order to have a separate PGraphics on a separate thread:
We config ARGS_SKETCH_FOLDER " --sketch-path" to match PApplet’s main sketch, so save functions know the root folder where the sketch is run:
final String[] switches = { ARGS_SKETCH_FOLDER + sketchPath(), "" };
runSketch(switches, layer = new Layer());
Layer is the 2nd PApplet subclass:
public static class Layer extends PApplet {
static final short INTERVAL = 1*1000, TXT_SIZE = 40;
static final float BOLD = 2.5;
static final color BORDER = 0, TXT_COLOR = -1;
PGraphics pg;
PImage img;
void settings() {
size(1, 1, P2D);
}