Hello, I am trying to use Processing as a rendering engine outside the PApplet
context.
The following test code works fine:
public static void main(String[] args) {
PGraphicsJava2D pg=new PGraphicsJava2D();
pg.setSize(400, 400);
pg.beginDraw();
pg.background(255);
pg.line(0,0,400,400);
pg.endDraw();
String filename=System.getProperty("user.dir")+File.separator+"picture.png";
pg.save(filename);
}
The problem is that when I try to use the OpenGL renderers, PGraphics2D
and PGraphics3D
instead, I get the following error:
Exception in thread “main” java.lang.NullPointerException: Cannot call “processing.core.PApplet.getSurface()” because “this.sketch” is null`.
How do I initialise the PGraphics2D/PGraphics3D
renderer correctly?
I am using the 3.3.6 version from the maven repository and the latest 4.x version from the jars in the processing editor, with the same results.
Thank you very much!