with second applet, strange errors about createGraphics

PGraphics canvas;

void setup() {
  size(400, 400, P3D);
  canvas = createGraphics(400, 400, P3D);

  String[] args = {"YourSketchNameHere"};
  SecondApplet sa = new SecondApplet();
  PApplet.runSketch(args, sa);
}

void draw() {

  canvas.beginDraw();
  canvas.background(127);
  canvas.lights();
  canvas.translate(width/2, height/2);
  canvas.rotateX(frameCount * 0.01);
  canvas.rotateY(frameCount * 0.01);  
  canvas.box(150);
  canvas.endDraw();
  image(canvas, 0, 0);
}     

public class SecondApplet extends PApplet {

  public void settings() {
    size(200, 100,P3D);
  }
  public void draw() {
    background(255);
    fill(0);
    ellipse(100, 50, 10, 10);
  }
}

With that code I get "createGraphics() requires size to use P3D or P2D" (paraphrasing)

Or if I try to create an instance of a Syphon window, for example, I get null pointer.

What's the deal? My goal is to create a 2-window app with Syphon output from one window and a P5 control setup on the other.

Answers

Sign In or Register to comment.