lwjgl glfwCreateWindow 导致崩溃
lwjgl glfwCreateWindow causes crash
我正在尝试使用 lwjgl 编写 opengl 渲染器。要打开 window,我使用的是 glfw。但是,当我调用 glfwCreateWindow 时,它因以下错误而崩溃:
Java运行时环境检测到致命错误:
PC=0x00007fff2d732924 处的 SIGSEGV (0xb),pid=64615,tid=775
JRE 版本:Java(TM) SE Runtime Environment (14.0.2+12) (build 14.0.2+12-46)
Java VM:Java HotSpot(TM) 64 位服务器 VM(14.0.2+12-46、混合模式、共享、分层、压缩 oops、g1 gc、bsd-amd64)
有问题的框架:
C [HIToolbox+0x27924] _ZNK22THIThemeTextInfoFinder10GetOptionsEv+0x8
不会写入核心转储。核心转储已被禁用。要启用核心转储,请在再次启动 Java 之前尝试“ulimit -c unlimited”
包含更多信息的错误报告文件保存为:
/Users/vic/eclipse-workspace/Engine/hs_err_pid64615.log
如果您想提交错误报告,请访问:
https://bugreport.java.com/bugreport/crash.jsp
这是我的代码:
package main;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWVidMode;
public class Main {
public static void main(String[] args) {
if(!GLFW.glfwInit()) {
System.err.println("Failed to initialize glfw");
System.exit(-1);
}
GLFW.glfwDefaultWindowHints();
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE);
long window = GLFW.glfwCreateWindow(640, 480, "My window", 0, 0);
if(window == 0) {
System.err.println("Failed to create window");
System.exit(-1);
}
GLFWVidMode videoMode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
GLFW.glfwSetWindowPos(window, (videoMode.width() - 640) / 2, (videoMode.height() - 480) / 2);
GLFW.glfwShowWindow(window);
while(!GLFW.glfwWindowShouldClose(window)) {
GLFW.glfwPollEvents();
}
GLFW.glfwTerminate();
}
}
我正在使用 mac 和 eclipse。
谢谢!
解决方案是将 -XstartOnFirstThread 添加到 JVM 参数中。
我正在尝试使用 lwjgl 编写 opengl 渲染器。要打开 window,我使用的是 glfw。但是,当我调用 glfwCreateWindow 时,它因以下错误而崩溃:
Java运行时环境检测到致命错误:
PC=0x00007fff2d732924 处的 SIGSEGV (0xb),pid=64615,tid=775
JRE 版本:Java(TM) SE Runtime Environment (14.0.2+12) (build 14.0.2+12-46) Java VM:Java HotSpot(TM) 64 位服务器 VM(14.0.2+12-46、混合模式、共享、分层、压缩 oops、g1 gc、bsd-amd64) 有问题的框架: C [HIToolbox+0x27924] _ZNK22THIThemeTextInfoFinder10GetOptionsEv+0x8
不会写入核心转储。核心转储已被禁用。要启用核心转储,请在再次启动 Java 之前尝试“ulimit -c unlimited”
包含更多信息的错误报告文件保存为: /Users/vic/eclipse-workspace/Engine/hs_err_pid64615.log
如果您想提交错误报告,请访问: https://bugreport.java.com/bugreport/crash.jsp
这是我的代码:
package main;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWVidMode;
public class Main {
public static void main(String[] args) {
if(!GLFW.glfwInit()) {
System.err.println("Failed to initialize glfw");
System.exit(-1);
}
GLFW.glfwDefaultWindowHints();
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE);
long window = GLFW.glfwCreateWindow(640, 480, "My window", 0, 0);
if(window == 0) {
System.err.println("Failed to create window");
System.exit(-1);
}
GLFWVidMode videoMode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
GLFW.glfwSetWindowPos(window, (videoMode.width() - 640) / 2, (videoMode.height() - 480) / 2);
GLFW.glfwShowWindow(window);
while(!GLFW.glfwWindowShouldClose(window)) {
GLFW.glfwPollEvents();
}
GLFW.glfwTerminate();
}
}
我正在使用 mac 和 eclipse。
谢谢!
解决方案是将 -XstartOnFirstThread 添加到 JVM 参数中。