java - 使用 LWJGL3 生成顶点数组时出现核心转储错误
问题描述
所以我试图开始使用 LWJGL3,我想制作一个简单的窗口,用存储在 GPU 中的顶点绘制 2 个三角形。我在运行代码时不断收到此错误 Java 检测到致命错误
Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f92f01996ec, pid=4580, tid=0x00007f93664c4700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_171-b11) (build 1.8.0_171-b11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.171-b11 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [liblwjgl_opengl.so+0x446ec] Java_org_lwjgl_opengl_GL30_nglGenVertexArrays__IJ+0xc
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
这是我的代码
private void loop() {
// This line is critical for LWJGL's interoperation with GLFW's
// OpenGL context, or any context that is managed externally.
// LWJGL detects the context that is current in the current thread,
// creates the GLCapabilities instance and makes the OpenGL
// bindings available for use.
GL.createCapabilities();
// Run the rendering loop until the user has attempted to close
// the window or has pressed the ESCAPE key.
while (!glfwWindowShouldClose(window)) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer
glBindVertexArray(vaoId);
glEnableVertexAttribArray(0);
glDrawArrays(GL_TRIANGLES, 0, vertexCount);
glDisableVertexAttribArray(0);
glBindVertexArray(0);
glfwSwapBuffers(window); // swap the color buffers
// Poll for window events. The key callback above will only be
// invoked during this call.
glfwPollEvents();
}
}
private void initTriangle() {
FloatBuffer vertBuf = MemoryUtil.memAllocFloat(vertices.length);
vertBuf.put(vertices);
vertBuf.flip();
vaoId = GL30.glGenVertexArrays();
GL30.glBindVertexArray(vaoId);
vboId = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertBuf, GL15.GL_STATIC_DRAW);
GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
GL30.glBindVertexArray(0);
}
我在循环之前调用 InitTriangle 并在 vaoId = GL30.glGenVertexArrays();
谁能告诉我我做错了什么或引导我朝着正确的方向前进,我将不胜感激。
解决方案
我在制作 GLCapabilites 之前调用了 initTriangle
推荐阅读
- javascript - 即使输入设置为“必需”,我的按钮仍在工作
- google-apps-script - 在工作表中插入我自己的联系方式 - Google Apps 脚本
- automapper - 使用自动映射 IF 忽略属性
- sql - 在起始值不是 1 的插入语句上分配唯一编号
- c# - C#:持有命名信号量的进程在没有释放的情况下死亡
- node.js - 我写的CLI不返回错误,正常返回错误文本
- c# - HttpListener 打开后忽略 websocket 请求
- styled-components - 样式组件不能与 scss bem 结构一起正常工作
- python - 使用 grid_mapping ValueError 保存 NetCDF
- python - 将列表中的每个元素与之前的所有连续元素进行比较