I have the following situation. I have a PGraphics that’s running without problems in the main window. I want to remove this PG from the main window and simply display it on a second window.
All the calculation and ControlP5 interaction are in the main thread so i won’t have any problems comunicating changes between threads. So i’ve checked the forums for an answer and tried a few of the solutions presented. but actually none of them worked. how do i pass the PG to the second window? i’ve tried sending the PGraphics in the constructor and nothing happened. Should i pass the PG to the second window in something like this:
win.draw(pg)
this is the situation i have now:
here’s the basic code
import controlP5.*;
import com.hamoid.*;
ControlP5 cp5;
VideoExport videoExport;
//second window
PWindow win;
ParticleSystem ps;
//PGraphics
PGraphics pg;
int w=2400;
int h=1920;
int pgOrigin=400;
//Particle Control
int speedX=0;
int speedY=0;
int spawn=0;
int pw=w;
int ph=30;
int spawnX=0;
int spawnY=h;
color fillColor=color(255);
//video export
boolean isRecording=false;
String filename="particleMaker";
void settings() {
  size(1020, 960, P2D);
  smooth();
}
void setup() {
  //setup ControlP5  
  controlP5Setup();
  //setup PG
  println("building PGraphics");
  pg=createGraphics(w, h, P2D);
  ps=new ParticleSystem();
 
  win=new PWindow();
  //setup videoexport
  videoExport = new VideoExport(this, filename+".mp4", pg);
  videoExport.startMovie();
}
void draw() {
  background(32);
  if (spawn>0 && frameCount % spawn==0) {
    ps.addParticle();
  }
  pg.beginDraw();
  pg.background(0);
  ps.run();
  pg.endDraw();
  image(pg, 400, 0, 600, 480);
  //saves();
  if (isRecording) {
    videoExport.saveFrame();
  }
}
void saves() {
  pg.save("saves/"+filename+"C/"+filename+"C-"+frameCount+".png");
}
void keyPressed() {
  if (key=='s') saves();
  if (key == 'r' || key == 'R') {
    isRecording = !isRecording;
    println("Recording is " + (isRecording ? "ON" : "OFF"));
  }
  if (key == 'q') {
    videoExport.endMovie();
  }
}
PWindow code
public class PWindow extends PApplet {
  PWindow() {
    super();
    PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
  }
  void settings() {
    size(600, 480);
  }
  void setup() {
    background(0);
  }
  void draw() {
    image(pg, 0, 0, 600, 480);
  }
}
            