I am currently attempting to update a program that utilizes OpenGL. I need to get the program to work on MacOS X 10.15. I am using JDK SE 14 and the most recent version of JOGL found at https://jogamp.org/.
The issue I run into is when the program tries to create a GLCanvas() or GLJPanel(), it will instantly crash. Below is the snippet of code that causes the crash.
public void initFrame(){
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
JRootPane root = frame.getRootPane( ); // make small title bar
root.putClientProperty( "Window.style", "small" );
GLCanvas canvas = new GLCanvas();
frame.setUndecorated(undecorated);
canvas.addGLEventListener(this);
canvas.addMouseListener(this);
canvas.addMouseMotionListener(this);
frame.setSize(frameWidth, frameHeight);
frame.setLocation(frameX,frameY);
frame.add(canvas);
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = env.getDefaultScreenDevice();
FPSAnimator animator = new FPSAnimator(canvas,33);
frame.setVisible(true);
animator.start();
}
The following error is produced when the code reaches GLCanvas canvas = new GLCanvas()
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary$3 (file:/Users/bendavidson/NetBeansProjects/mlsim-master/lib/gluegen-rt.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String)
WARNING: Please consider reporting this to the maintainers of com.jogamp.common.os.NativeLibrary$3
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-08-24 14:59:37.054 java[1489:26665] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff31959797 __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff6a653a9e objc_exception_throw + 48
2 CoreFoundation 0x00007fff3198211c -[NSException raise] + 9
3 AppKit 0x00007fff2eb6eddc -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 310
4 AppKit 0x00007fff2eb56842 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416
5 AppKit 0x00007fff2eb562b3 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
6 libnativewindow_macosx.jnilib 0x000000012f2053fe Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 + 398
7 ??? 0x000000011c5bb6b0 0x0 + 4770739888
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Java Result: 134
I am not sure how to interpret this error, and was wondering if there were any workarounds to getting GLCanvas() to work on MacOS X 10.15. I plan to switch the entire application to Metal in the coming months, but I need a quick fix for an upcoming project.