I have an application that integrates JOGL into Swing. It has been stable for years in Java 8/9/10. I am now trying to migrate to Java 11+ using JOGL 2.4.0.
After trying several vendors and versions of JDK, they all have the same behavior: my NewtCanvasAWT no longer appears.
It is added to the ContentPane of a JInternalFrame with:
newtCanvasAWT = new NewtCanvasAWT(glWindow);
final Container container = new Container();
Visually, it is as if the ContentPane is empty. In terms of processing, everything still works correctly. The call stacks get executed fully and OpenGL buffers are written to. This is confirmed by AWTGLReadBufferUtil.readPixelsToBufferedImage() still returning a rendered buffer.
Has something changed in Java 11 with how JOGL/NewtCanvasAWT/something interacts with Swing? Or maybe my method of adding to Container and ContentPane is no longer fully correct?
If anyone has any ideas, I would appreciate it. Thank you!
Using a dummy java.awt.Canvas object with a background color does NOT work. This implies the issues is with java.awt.Canvas heavy weight component integration with Swing light weight system. I will look more into this.
I do not believe there is any issues with JOGL itself.
This is for a desktop application for Windows. I have only tested on Windows 10.
My current best theory is that it is an issue with mixing the heavyweight AWT Canvas with lightweight Swing components causing some sort of validation or z-layer issue. However, this does not explain why a regression occurred from Java 10 to Java 11+.
I have found that "-Dsun.awt.disableMixing=true" will make the awt.Canvas's show. However, this is not a realistic solution because it disables the proper layering interaction between the Canvas surfaces with the rest of the Swing application.
After more investigation, I determined the issue was the result of 3rd party libraries putting translucent panes/components over the top of the Canvas. Why rendering behavior change from JDK 10 to 11, I do not know.
Ultimately this is a reminder that mixing heavyweight AWT into Swing is quite finicky (but is needed for high performance scenarios like 3d graphics).