微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

是否可以在MacOS X 10.15Java上创建OpenGL,GLCanvas元素?

如何解决是否可以在MacOS X 10.15Java上创建OpenGL,GLCanvas元素?

我当前正在尝试更新利用OpenGL的程序。我需要使该程序在MacOS X 10.15上运行。我正在使用JDK SE 14和https://jogamp.org/中找到的JOGL的最新版本。 我遇到的问题是,当程序尝试创建GLCanvas()GLJPanel()时,它将立即崩溃。以下是导致崩溃的代码段。

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();
}

代码到达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

我不确定如何解释此错误,并且想知道是否有任何变通办法可以使GLCanvas()在MacOS X 10.15上运行。我计划在接下来的几个月中将整个应用程序切换到Metal,但是我需要为即将到来的项目快速修复。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。