Processing 3 OpenGL in a Java app

edited December 2015 in Questions about Code

I'm trying to figure out how to get Processing 3 to play nicely as a library in a Java app. The app might potentially have Swing and/or AWT components somewhere in its lifecycle. I don't necessarily need the Swing and AWT stuff to be on screen AT THE SAME TIME as the Processing rendered stuff, but they need to at least be in the same window or full screen display. Using the Java2D renderer I can sort of do this like so (as referenced in some other threads):

in my PApplet based class:

public SmoothCanvas getCanvas() {
  PSurfaceAWT awtSurface = (PSurfaceAWT)surface;
  PSurfaceAWT.SmoothCanvas smoothCanvas = (PSurfaceAWT.SmoothCanvas)awtSurface.getNative();
  return smoothCanvas;
}

In my main class, which extends JFrame:

String[] args = {TestApplet.class.getName()};
ControlApplet app = new TestApplet();
TestApplet.runSketch(args, app);

JFrame pFrame = (JFrame) app.getCanvas().getFrame();
pFrame.setVisible(false);
getContentPane().add(app.getCanvas());
pFrame.dispose(); 

That achieves the goal, however there are two problems: it still pops up the initial Processing window for a brief second until I am able to gab the Frame and attach it to the base JFrame, and it only works in Java2D.

I'm trying to get my head around the hierarchy of JOGL and how I can grab ahold of a container somewhere that I might be able to attach to a "regular" Java container of some sort. Any insights on how I might do this?

Sign In or Register to comment.