使用 stb_image 的 stbi_load
Using stb_image's stbi_load
我正在使用 lwjgl 的 stb_image
端口加载 jpg
图像。
问题是,我总是得到一个 null
到 ByteBuffer
,因为没有加载任何东西。
这是代码:
int[] width = new int[1], height = new int[1], nrChannels = new int[1];
ByteBuffer data = stbi_load("/textures/container.jpg",width, height,nrChannels,0);
if(data == null)
throw new RuntimeException("Failed to load texture."); //I get this exception.
我的贴图位置:
我当然试过了:
ByteBuffer data = stbi_load("container.jpg",width, height,nrChannels,0);
同样的结果,没有加载。
我究竟做错了什么?
您给 stbi_load() 的路径不是类路径资源,而是文件系统路径。
我正在使用 lwjgl 的 stb_image
端口加载 jpg
图像。
问题是,我总是得到一个 null
到 ByteBuffer
,因为没有加载任何东西。
这是代码:
int[] width = new int[1], height = new int[1], nrChannels = new int[1];
ByteBuffer data = stbi_load("/textures/container.jpg",width, height,nrChannels,0);
if(data == null)
throw new RuntimeException("Failed to load texture."); //I get this exception.
我的贴图位置:
我当然试过了:
ByteBuffer data = stbi_load("container.jpg",width, height,nrChannels,0);
同样的结果,没有加载。 我究竟做错了什么?
您给 stbi_load() 的路径不是类路径资源,而是文件系统路径。