我正在尝试使用stbi_load
. 但是,控制台中会抛出以下错误
Java 运行时环境检测到致命错误:EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffb5bb63b8c, pid=5424, tid=0x0000000000001364 JRE 版本:OpenJDK 运行时环境 (8.0_312-b07) (build 1.8.0_312-b07) Java VM OpenJDK 64 位服务器 VM(25.312-b07 混合模式 windows-amd64 压缩 oops)有问题的框架:C [lwjgl_stb.dll+0x3b8c] 无法写入核心转储。Windows 客户端版本默认不启用 Minidump 包含更多信息的错误报告文件保存为:C:\Users\nottn\eclipse-workspace\Bon Sea\hs_err_pid5424.log 如果您想提交错误报告,请访问:https ://bugzilla.redhat.com/enter_bug.cgi崩溃发生在 Java 虚拟机之外的本地代码中。请参阅有问题的框架以了解报告错误的位置。
这是产生此错误的代码(请记住,我正在使用 LWJGL 3)
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.stb.STBImage.*;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.awt.image.BufferedImage;
public class Texture {
private int id;
private IntBuffer width, height, n;
public Texture(String filename)
{
BufferedImage bi;
try
{
bi = ImageIO.read(new File("./sprites/" + filename));
width = IntBuffer.allocate(bi.getWidth());
width.put(bi.getWidth());
height = IntBuffer.allocate(bi.getHeight());
height.put(bi.getHeight());
n = IntBuffer.allocate(GL_RGBA);
n.put(GL_RGBA);
ByteBuffer data = stbi_load("/Users/nottn/eclipse-workspace/Bon Sea/sprites/test.png", width, height, n, STBI_rgb_alpha);
id = glGenTextures();
glBindTexture(GL_TEXTURE_2D, id);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width.array()[0], height.array()[0], 0, GL_RGBA, GL_BYTE, data);
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void Bind() {
glBindTexture(GL_TEXTURE_2D, id);
}
}
这是生成的日志文件Pastebin Log Here
非常感谢有关为什么会发生此错误的任何答案。