> On Mar 15, 2023, at 4:34 AM, Martin Pernollet > <[email protected]> wrote: > > My answer is not published because I sent a too big image. Please find it > below without image : > > > We access OpenGL through native bindings generated by JExtract, from project > Panama. These bindings are packaged as a library visible here > (https://gitlab.com/jzy3d/panama-gl). > > The -XstartOnFirstThread option is needed by OpenGL on macOS as OpenGL > invocation MUST be performed from macOS main thread. > > Not using this option on macOS lead to an error > > java[92246:2751169] GLUT Fatal Error: internal error: > NSInternalInconsistencyException, reason: NSWindow drag regions should only > be invalidated on the Main Thread! > > Using this option on macOS lead to a freeze in LockSupport.park() (see the > attached image for the complete call stack) > > JOGL has a smart way of solving this with a class allowing to push Runnables > to macOS main thread > (https://github.com/jzy3d/jogl/blob/ecf6e499d3b582d651a28693c871ca14d6e8c991/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java#L305) > based on ObjectiveC code from Apple's AppKit framework > (https://github.com/jzy3d/jogl/blob/ecf6e499d3b582d651a28693c871ca14d6e8c991/src/nativewindow/native/macosx/OSXmisc.m#L1167). > This allows running on Swing without having to use the -XstartOnFirstThread. > > However JOGL has several issues, one of these being that it freezes JVM>=19 > as soon as it appears in the classpath (for other reasons than the one > discussed above). > > This issue is a real pain for anyone publishing applications involving OpenGL > in Swing - whatever the OpenGL binding framework. Not solving the issue would > make project Panama unusable for computer graphics. > > Regards, > > Martin >
Apologies if not of interest but it seems somewhat on-topic. I have some very old code that might be of use? http://mikehall.pairserver.com/javasrc.html#onmain OnMain: not a bad place to have your Cocoa Java served up - 10/14/06 NSAppleScript execution and possibly other Cocoa Java classes should be run on the AppKit 'main' thread. OnMain.dmg provides a small JNI stub to do a callback to java on the main thread that should provide this. 10/28/2006 - More new functionality. Added Some JNI, generated of course, execution of the AppleScript related 10/22/2006 - Added some additional AppleScript testing and a couple execution option switches. More or less documented in the README file. http://mikehall.pairserver.com/OnMain.dmg
