As an experiment, I tried using createGraphics() with p5Sunflow as the renderer:
----------------
Code:
import hipstersinc.sunflow.*;
import hipstersinc.sunflow.shader.*;
import hipstersinc.*;
import processing.opengl.*;
PGraphics sunflow;
void setup() {
size(400, 300, P3D);
frameRate(15);
}
void draw() {
background(255);
camera(300, -300, 300, 0, 0, 0, 0, -1, 0);
perspective();
fill(255, 150, 0);
box(100, 100, 100);
}
void keyPressed() {
if (key == 'r') {
sunflowRender();
}
}
void sunflowRender() {
println("Beginning Sunflow render...");
noLoop();
sunflow = createGraphics(400, 300, "hipstersinc.P5Sunflow");
sunflow.beginDraw();
sunflow.background(255);
sunflow.camera(300, -300, 300, 0, 0, 0, 0, -1, 0);
sunflow.perspective();
sunflow.fill(255, 150, 0);
sunflow.box(100, 100, 100);
sunflow.endDraw();
sunflow.save("output.tif");
println("Sunflow render complete.");
loop();
}
--------------
Calling sunflowRender() throws the following exception:
----------------
Code:
java.lang.NullPointerException
at hipstersinc.P5Sunflow.<init>(P5Sunflow.java:59)
java.lang.NullPointerException
at hipstersinc.P5Sunflow.<init>(P5Sunflow.java:59)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at processing.core.PApplet.createGraphics(PApplet.java:1218)
at processing.core.PApplet.createGraphics(PApplet.java:1124)
at Temporary_2874_7633.sunflowRender(Temporary_2874_7633.java:30)
at Temporary_2874_7633.keyPressed(Temporary_2874_7633.java:23)
at processing.core.PApplet.handleKeyEvent(PApplet.java:2016)
at processing.core.PApplet.dequeueKeyEvents(PApplet.java:1992)
at processing.core.PApplet.handleDisplay(PApplet.java:1495)
at processing.core.PGraphics.requestDisplay(PGraphics.java:690)
at processing.core.PApplet.run(PApplet.java:1562)
at java.lang.Thread.run(Thread.java:613)
java.lang.RuntimeException
at processing.core.PApplet.createGraphics(PApplet.java:1235)
at processing.core.PApplet.createGraphics(PApplet.java:1124)
at Temporary_2874_7633.sunflowRender(Temporary_2874_7633.java:30)
at Temporary_2874_7633.keyPressed(Temporary_2874_7633.java:23)
at processing.core.PApplet.handleKeyEvent(PApplet.java:2016)
at processing.core.PApplet.dequeueKeyEvents(PApplet.java:1992)
at processing.core.PApplet.handleDisplay(PApplet.java:1495)
at processing.core.PGraphics.requestDisplay(PGraphics.java:690)
at processing.core.PApplet.run(PApplet.java:1562)
at java.lang.Thread.run(Thread.java:613)
----------------
Right now I'm exporting geometry and rendering it with Sunflow in a separate sketch, which works fine... but it would be super cool to have Sunflow render in the background from a single sketch.