In the course of rebuilding a big Processing project in a Java IDE (IntelliJ) on Windows 10 x64, Processing 3.5.4, I try to translate the old solution for running two Processing threads, one in 2D, one in 3D on different screens:
The processing code can be found here: 3D renderer not recognized in secondApplet - Processing 2.x and 3.x Forum (scroll down to the last code version)
But with my Java code I get error messages in the IntelliJ IDE (see below). I suppose the problem is related to the runSketch method. Could anybody suggest how to solve this?
My Java code:
import processing.core.PApplet;
import processing.core.PShape;
public class TwoThreads extends PApplet {
public static void main(String[] args)
{
PApplet.main("TwoThreads", args);
}
public void settings() {
size(400, 300, JAVA2D);
smooth(3);
noLoop();
String[] args = {"SecondApplet"};
SecondApplet sa = new SecondApplet();
PApplet.runSketch(args, sa);
}
public void draw()
{
line(5, 5, 50, 50);
}
public class SecondApplet extends PApplet {
Tetra tetra;
float theta;
public void settings() {
size(400, 300, P3D);
}
public void setup() {
frameRate(30);
//PVector myVec = new PVector(width>>1, height>>1, 0300);
//circle = new MyCircle(this, myVec, #FFFF00);
tetra = new Tetra(this, 10);
theta = (float) 0.0;
}
public void draw() {
background(255);
theta += 0.01;
translate(width/2, height/2, 0);
rotateX(theta);
rotateY(theta);
// translate the scene again
translate(100, 100, 20);
background(0100);
//translate(mouseX, mouseY, 20);
//circle.display();
//translate(mouseX, mouseY, 0);
tetra.display();
//box(100);
}
}
public class Tetra {
final PApplet p;
// The PShape object
final PShape gr;
int t;
float speed;
Tetra(PApplet pa, int t_) {
p = pa;
t = t_;
gr = p.createShape();
gr.beginShape(TRIANGLES);
gr.fill(150, 0, 0, 127);
gr.vertex(-t, -t, -t);
gr.vertex( t, -t, -t);
gr.vertex( 0, 0, t);
gr.fill(0, 150, 0, 127);
gr.vertex( t, -t, -t);
gr.vertex( t, t, -t);
gr.vertex( 0, 0, t);
gr.fill(0, 0, 150, 127);
gr.vertex( t, t, -t);
gr.vertex(-t, t, -t);
gr.vertex( 0, 0, t);
gr.fill(150, 0, 150, 127);
gr.vertex(-t, t, -t);
gr.vertex(-t, -t, -t);
gr.vertex( 0, 0, t);
gr.endShape();
}
Tetra display() {
//p.box(100);
p.shape(gr);
return this;
}
}
}
Error messages from IntelliJ IDE:
java.lang.NoClassDefFoundError: com/jogamp/opengl/GLCapabilitiesImmutable
at processing.opengl.PGraphicsOpenGL.createPGL(PGraphicsOpenGL.java:712)
at processing.opengl.PGraphicsOpenGL.(PGraphicsOpenGL.java:569)
at processing.opengl.PGraphics3D.(PGraphics3D.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at processing.core.PApplet.makeGraphics(PApplet.java:2266)
at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2345)
at processing.core.PApplet.initSurface(PApplet.java:10983)
at processing.core.PApplet.runSketch(PApplet.java:10922)
at TwoThreads.settings(TwoThreads.java:19)
at processing.core.PApplet.handleSettings(PApplet.java:978)
at processing.core.PApplet.runSketch(PApplet.java:10897)
at processing.core.PApplet.main(PApplet.java:10657)
at TwoThreads.main(TwoThreads.java:9)
Caused by: java.lang.ClassNotFoundException: com.jogamp.opengl.GLCapabilitiesImmutable
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
… 16 more
java.lang.RuntimeException: com/jogamp/opengl/GLCapabilitiesImmutable
at processing.core.PApplet.makeGraphics(PApplet.java:2299)
at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2345)
at processing.core.PApplet.initSurface(PApplet.java:10983)
at processing.core.PApplet.runSketch(PApplet.java:10922)
at TwoThreads.settings(TwoThreads.java:19)
at processing.core.PApplet.handleSettings(PApplet.java:978)
at processing.core.PApplet.runSketch(PApplet.java:10897)
at processing.core.PApplet.main(PApplet.java:10657)
at TwoThreads.main(TwoThreads.java:9)Process finished with exit code 1