当前位置: 首页 > 知识库问答 >
问题:

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

鞠嘉誉
2023-03-14

我试图用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
<terminated>

共有1个答案

陈增
2023-03-14

确保使用jvm标志-XStartonFirstThread运行应用程序。虽然这似乎是专门针对OSX的。看到这个,所以回答这个论点是什么意思

 类似资料:
  • 任务:Main.Main()失败无法创建窗口 执行任务“:main.main()”失败。 进程“命令”c:/program files/java/jdk-16/bin/java.exe“以非零退出值-1结束 null null

  • 我试图用LWJGL编写一个opengl渲染器。为了打开窗户,我用的是GLFW。但是,当我调用glfwCreateWindow时,它会崩溃,出现以下错误: Java运行时环境检测到一个致命错误: 谢了!

  • 我有两台显示器;创建 LWJGL 窗口时: 它总是出现在我的左侧屏幕上。是否有一个参数可以设置以更改它出现在哪个屏幕上,例如:

  • 我在用lwjgl 3,学习现代opengl (3)。我想发送一个统一的矩阵到顶点着色器,这样我就可以应用变换。我试过了,程序崩溃了,并出现了这个错误 显然我做错了什么。 问题似乎出在这行代码上 如果我删除这一行代码,程序会正确执行。< br > 我试着传递一个对角矩阵来检查问题是否出在矩阵本身,但还是得到了同样的结果 mvp是我传递给着色器的对角矩阵。< br> uniformMatrixLoca

  • 我试图从我的框架中获得轮廓,这就是我所做的: .................................................... 程序在处崩溃,我收到以下错误消息: OpenCV错误:不支持的格式或格式组合([开始]FindContour只支持8uC1和32sC1图像)在未知的功能,文件......\src\openc v\模块\imgproc\src\contours.cp

  • 我在MacOS上使用Intellij。我对编程比较陌生,并从LWJGL网站上学习本教程。我遵循了所有的说明,并在VM选项中添加了-XStartonFirstThread。但是,每当我在IntelliJ中运行程序(HelloWorld.java),我就会看到停靠站中的java exec窗口,并得到“Hello LWJGL 3.2.3 build 13!”在控制台,但窗户打不开,我根本看不到窗户。