I’m working to integrate 3D via JOGL into a Swing app. I have no issues getting a GLJPanel up and running, but am not able to get either the GLCanvas or the Java2D/OpenGL pipeline with the GLJPanel working. If we can get the GLCanvas to work we’d like to use that instead of the GLJPanel for the purported speed benefits.
The app in question contains customized Swing rendering, including a custom RepaintManager, and double-buffering disabled. I have an instance of a GLCanvas parented under a specialization of a JPanel (that overrides method “paint” to force a paint on the child canvas). Furthermore, due to the custom rendering in the app, I have to reposition the GLCanvas via a custom layout manager to make it viewable in its JPanel parent. This approach works great when I replace the GLCanvas with just a regular old Canvas (with a custom paint method that just paints a couple of lines). The canvas and the lines are present and visible within the JPanel. When I plop in the GLCanvas (really a tweak of the JGears demo app made to work with GLCanvas) nothing renders. I can set the background color of the GLCanvas to be red, and when my JPanel appears, I see the red GLCanvas for about a quarter-second, then it disappears, as if as soon as the 3D initializes the GLCanvas repaints or becomes translucent?
I see no JOGL related exceptions, I’ve enabled the JOGL debugging/profiling and see the profiling stats related to locking, swapBuffers, etc, so it appears that the animation is indeed running… just nothing is visible.
My four theories as to what is going wrong are:
* The OpenGL rendering is being hidden by the ART/Swing painting over top of it. I doubt this is the case, as I’d probably see some level of flickering, and I don’t.
* The OpenGL rendering is being done to a location not visible on the screen. I guess this is possible, but why would things work correctly with a plain old Canvas?
* The OpenGL rendering needs an AWT parent to properly trigger a repaint? In our setup the parent of the GLCanvas is a JPanel. I was able to get an instance of the GLCanvas running the JGears demo up and running in this app by placing it as a direct child of app’s JFrame. The app is designed to have a single JComponent child of the JFrame that manages (though the custom rendering) all of the other Swing components. Placing the JPanel wrapped GLCanvas as a sibling of this JComponent avoids the custom rendering path and, by golly, allows it to render.
* The custom rendering in this app is somehow intercepting or otherwise interfering with the GLCanvas swapBuffers operation. In JOGL, after a GLCanvas native onscreen drawable executes swapBuffers, is there something in AWT that actually triggers the final step in the rendering process? Or is the native swapbuffer call the final step?
I know everything that I’ve outlined here is pretty vague, but if anyone has any ideas as to what could be going wrong, or even just some tips on what I could/should look at, or even just some pointers on the overall JOGL OpenGL AWT/Swing rendering cycle, I’d greatly appreciate it!