As far as it goes for other threads, it sounds like you have the right rules. Keep in mind that JOGL by default forces everything onto the AWT thread internally, so you'll have to call Threading.disableSingleThreading() to correctly get different threads to work.
Is this still required if you aren't using a GLCanvas and building the GLDrawable directly?
I'm using the following code to associate a GLDrawable to a Frame. I'm actually surprised this is working.
1 2 3 4 5 6
| private static Frame frame; private static GLCapabilities capabilities; private static GLDrawable drawable; private static GLContext context; private static GL gl; private static GLU glu; |
Part of a makeFrame method called from the main method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| capabilities = new GLCapabilities(); AWTGraphicsDevice dev = new AWTGraphicsDevice(null); AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration) GLDrawableFactory.getFactory().chooseGraphicsConfiguration(capabilities, null, dev); GraphicsConfiguration config = null; if (awtConfig != null) config = awtConfig.getGraphicsConfiguration(); frame = new Frame(title, config); frame.setSize(PWIDTH,PHEIGHT); frame.setFocusable(true); frame.requestFocus(); drawable = GLDrawableFactory.getFactory().getGLDrawable(frame, capabilities, null); context = drawable.createContext(null);
...
frame.setVisible(true); |
The main method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| long period = (long)(1000.0 / DEFAULT_FPS) * 1000000L; makeFrame("CubeGL (Active)", period); while (!frame.isDisplayable()) Thread.yield(); drawable.setRealized(true);
stats = new FrameStatistics(period); rot = new Rotator3D(); init();
loop();
stats.printStats(); context.destroy(); System.exit(0); |