java - LWJGL:打开窗口导致程序崩溃

标签 java opengl lwjgl

我正在尝试用 Java/LWJGL 制作一个简单的游戏。我正在按照在 Windows 上制作的教程进行操作,而我正在使用 Mac。我复制了他为字符打开窗口字符的代码,程序立即崩溃,给我一个很长很奇怪的错误,可能与指针有关(我实际上不知道)。这是我在属性中定义宽度和高度时使用的用于创建窗口的行:

 window = glfwCreateWindow(width, height, "Flappy Bird", NULL, NULL);

当我在我的 mac 上运行它时,它给我这个错误:

2015-10-12 13:18:38.475 java[496:31875] *** Assertion failure in + [NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-1154/Misc.subproj/NSUndoManager.m:340
2015-10-12 13:18:38.476 java[496:31875] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2015-10-12 13:18:38.476 java[496:31875] (
0   CoreFoundation                      0x00007fff98c3003c __exceptionPreprocess + 172
1   libobjc.A.dylib                     0x00007fff9620a76e objc_exception_throw + 43
2   CoreFoundation                      0x00007fff98c2fe1a +[NSException raise:format:arguments:] + 106
3   Foundation                          0x00007fff99f6199b -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4   Foundation                          0x00007fff99ee364f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 156
5   AppKit                              0x00007fff96ecbb95 -[NSApplication run] + 756
6   libglfw.dylib                       0x000000010d597974 initializeAppKit + 1332
7   libglfw.dylib                       0x000000010d597035 _glfwPlatformCreateWindow + 37
8   libglfw.dylib                       0x000000010d59397b glfwCreateWindow + 443
9   ???                                 0x0000000104411eee 0x0 + 4366343918
10  ???                                 0x0000000104406929 0x0 + 4366297385
11  ???                                 0x0000000104406929 0x0 + 4366297385
12  ???                                 0x0000000104406929 0x0 + 4366297385
13  ???                                 0x000000010440685a 0x0 + 4366297178
14  ???                                 0x0000000104406d34 0x0 + 4366298420
)
2015-10-12 13:18:38.477 java[496:31875] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-1154/Misc.subproj/NSUndoManager.m:340
2015-10-12 13:18:38.477 java[496:31875] An uncaught exception was raised
2015-10-12 13:18:38.477 java[496:31875] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2015-10-12 13:18:38.477 java[496:31875] (
0   CoreFoundation                      0x00007fff98c3003c __exceptionPreprocess + 172
1   libobjc.A.dylib                     0x00007fff9620a76e objc_exception_throw + 43
2   CoreFoundation                      0x00007fff98c2fe1a +[NSException raise:format:arguments:] + 106
3   Foundation                          0x00007fff99f6199b -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4   Foundation                          0x00007fff99ee364f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 156
5   AppKit                              0x00007fff96ecbc41 -[NSApplication run] + 928
6   libglfw.dylib                       0x000000010d597974 initializeAppKit + 1332
7   libglfw.dylib                       0x000000010d597035 _glfwPlatformCreateWindow + 37
8   libglfw.dylib                       0x000000010d59397b glfwCreateWindow + 443
9   ???                                 0x0000000104411eee 0x0 + 4366343918
10  ???                                 0x0000000104406929 0x0 + 4366297385
11  ???                                 0x0000000104406929 0x0 + 4366297385
12  ???                                 0x0000000104406929 0x0 + 4366297385
13  ???                                 0x000000010440685a 0x0 + 4366297178
14  ???                                 0x0000000104406d34 0x0 + 4366298420
)
2015-10-12 13:18:38.478 java[496:31875] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
0   CoreFoundation                      0x00007fff98c3003c __exceptionPreprocess + 172
1   libobjc.A.dylib                     0x00007fff9620a76e objc_exception_throw + 43
2   CoreFoundation                      0x00007fff98c2fe1a +[NSException raise:format:arguments:] + 106
3   Foundation                          0x00007fff99f6199b -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4   Foundation                          0x00007fff99ee364f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 156
5   AppKit                              0x00007fff96ecbc41 -[NSApplication run] + 928
6   libglfw.dylib                       0x000000010d597974 initializeAppKit + 1332
7   libglfw.dylib                       0x000000010d597035 _glfwPlatformCreateWindow + 37
8   libglfw.dylib                       0x000000010d59397b glfwCreateWindow + 443
9   ???                                 0x0000000104411eee 0x0 + 4366343918
10  ???                                 0x0000000104406929 0x0 + 4366297385
11  ???                                 0x0000000104406929 0x0 + 4366297385
12  ???                                 0x0000000104406929 0x0 + 4366297385
13  ???                                 0x000000010440685a 0x0 + 4366297178
14  ???                                 0x0000000104406d34 0x0 + 4366298420
)
libc++abi.dylib: terminating with uncaught exception of type NSException

还会弹出一个窗口,提示“使用 libglfw.dylib 插件时 java 意外退出。”

我是否安装了 LWJGL 错误或我的代码有缺陷?感谢您的帮助!

<terminated>

最佳答案

确保您使用 jvm 标志 -XstartOnFirstThread 运行您的应用程序。尽管这似乎专门针对 OSX。 See this SO Answer what this argument means

关于java - LWJGL:打开窗口导致程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33087076/

相关文章:

java - 客户端在监听服务器时主动等待

java反射superClass被hibernate加载的问题

java - Dozer 未正确映射集合

java - token 语法错误 'class' @ expected [JAVA - LWJGL]

java - 读/写 txt 文件以保存

java - 如何使用恢复按钮进入上一个 Activity ?

opengl - 关于glm四元数旋转

Java渲染LWJGL 3.0.0

java - 尝试释放内存时出现 EXCEPTION_ACCESS_VIOLATION (0xc0000005)

c++ - 使用 g++ 链接对象时出现问题