Hello,
I made a simple model viewer and wanted to use a Drop library for drag and drop. I had to use a second 2D window with default renderer in order to drag and drop. It works great on windows, but not on macOS.
I used this example , but it doesn’t work to have a P3D as main window and default renderer as applet.
I made the code really barebone for testing
SecondApplet sa;
void settings() {
size(512, 512, P3D);
}
void setup() {
String[] args = {"blah"};
sa = new SecondApplet();
PApplet.runSketch(args, sa);
}
void draw() {
background(0);
}
public class SecondApplet extends PApplet {
public void settings() {
size(200, 200);
}
public void setup() {
}
public void draw() {
background(255);
}
}
but I’m getting following error:
RunnableTask.run(): A caught exception occured on thread main-Display-.macosx_nil-1-EDT-1: RunnableTask[enqueued true[executed false, flushed false, thread[0x512c8489, main-Display-.macosx_nil-1-EDT-1]], tTotal 0 ms, tExec 0 ms, tQueue 0 ms, attachment null, throwable java.lang.RuntimeException: Waited 5000ms for: <713d35ee, 54b3588e>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.macosx_nil-1-EDT-1>]
java.lang.RuntimeException: Waited 5000ms for: <713d35ee, 54b3588e>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.macosx_nil-1-EDT-1>
at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
at jogamp.newt.WindowImpl$ResizableAction.run(WindowImpl.java:2159)
at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:447)
at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:2859)
at jogamp.newt.WindowImpl.setResizable(WindowImpl.java:2195)
at com.jogamp.newt.opengl.GLWindow.setResizable(GLWindow.java:371)
at processing.opengl.PSurfaceJOGL.lambda$setResizable$5(PSurfaceJOGL.java:436)
at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:125)
at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:375)
DefaultEDT.run(): Caught exception occured on thread main-Display-.macosx_nil-1-EDT-1: RunnableTask[enqueued false[executed true, flushed false, thread[0x512c8489, main-Display-.macosx_nil-1-EDT-1]], tTotal 5010 ms, tExec 5010 ms, tQueue 0 ms, attachment null, throwable java.lang.RuntimeException: Waited 5000ms for: <713d35ee, 54b3588e>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.macosx_nil-1-EDT-1>]
java.lang.RuntimeException: Waited 5000ms for: <713d35ee, 54b3588e>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-Display-.macosx_nil-1-EDT-1>
at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
at jogamp.newt.WindowImpl$ResizableAction.run(WindowImpl.java:2159)
at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:447)
at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:2859)
at jogamp.newt.WindowImpl.setResizable(WindowImpl.java:2195)
at com.jogamp.newt.opengl.GLWindow.setResizable(GLWindow.java:371)
at processing.opengl.PSurfaceJOGL.lambda$setResizable$5(PSurfaceJOGL.java:436)
at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:125)
at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:375)
I tried switching the renderers of the windows, so default on main and p3d on second. Which totally worked fine, but when I try to switch those windows in the already mentioned example i’m getting errors left and right with everything I try. From unsupported file to ArrayIndexOutOfBoundsException (due to wrong placement)
One of my rewritings with switched windows:
// DRAG + DROP
import drop.*;
SDrop drop;
MyDropListener m;
PShape img;
String imgPath = "";
// second window
SecondApplet sa;
boolean saInit = true;
void settings() {
size(200, 200);
}
void setup() {
surface.setResizable(true);
surface.setTitle("dragImage");
drop = new SDrop(this);
m = new MyDropListener();
drop.addDropListener(m);
String[] args = {"blah"};
sa = new SecondApplet();
PApplet.runSketch(args, sa);
}
void draw() {
if (saInit) {
surface.setLocation(0, 0);
saInit= false;
}
background(255);
m.draw();
}
// a custom DropListener class.
class MyDropListener extends DropListener {
int myC = 0;
MyDropListener() {
setTargetRect(0, 0, width, height);
}
void draw() {
sa.noStroke();
sa.fill(0, 255, 0, myC);
sa.rect(0, 0, width, height);
sa.stroke(0);
}
void dropEnter() {
myC = 100;
}
void dropLeave() {
myC = 0;
}
void dropEvent(DropEvent theEvent) {
img = null;
imgPath = theEvent.toString();
img = loadShape(imgPath);
}
}
public class SecondApplet extends PApplet {
public void settings() {
size(512, 512, P3D);
}
public void setup() {
surface.setResizable(true);
}
public void draw() {
background(0);
if (img != null) {
shape(img, 0, 0);
}
}
}