java - lwjgl glfwCreateWindow 导致崩溃
问题描述
我正在尝试用 lwjgl 编写一个 opengl 渲染器。要打开窗口,我使用的是 glfw。但是,当我调用 glfwCreateWindow 时,它会因以下错误而崩溃:
Java 运行时环境检测到一个致命错误:
SIGSEGV (0xb) 在 pc=0x00007fff2d732924,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-Bit Server 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 参数中。
推荐阅读
- javascript - npm 错误!代码 ENOENT 和 npm ERR!系统调用产生 C:\Program Files\nodejs\node.exe
- caching - AEM Dispatcher 缓存规则
- android-studio - EditText 多重编辑填充检查
- reactjs - 如何使用 reactjs 和 typescript 将 prop 指定为可选?
- css - 时间轴 CSS 卡片序列
- amazon-web-services - 如何以用户身份在 Ceph 中创建主题
- react-native - React Native Navigation - 添加 headerRight 导致标题从左侧推开
- c# - 多个可选参数,包括 ASP.NET Core Web API 路由中的枚举类型
- solr - 仅查询期间的 Apache Solr 同义词
- javascript - 在 create-react-app 中启用生产中的 javascript 源映射