From what I'm guessing, SeekableByteChannels doesn't load URLs from the Internet. This is what I currently use to load textures from local storage:
public static Texture loadTexture(String location) throws IOException {
ByteBuffer rawImage = ioResourceToByteBuffer(location);
IntBuffer w = BufferUtils.createIntBuffer(1);
IntBuffer h = BufferUtils.createIntBuffer(1);
IntBuffer d = BufferUtils.createIntBuffer(1);
ByteBuffer storage = STBImage.stbi_load_from_memory(rawImage, w, h, d, 4);
if(storage == null) {
System.out.println(STBImage.stbi_failure_reason());
}
MemoryUtil.memFree(rawImage);
return new Texture().create(w.get(), h.get(), new Texture.Parameters(), storage);
}
private static ByteBuffer ioResourceToByteBuffer(String location) throws IOException {
ByteBuffer buffer = null;
Path path = Paths.get(location);
if(Files.isReadable(path)) {
SeekableByteChannel byteChannel = Files.newByteChannel(path);
buffer = BufferUtils.createByteBuffer((int) (byteChannel.size()+1));
while((byteChannel.read(buffer)) != -1);
}
return (ByteBuffer)buffer.flip();
}
How would I get STB to load a texture from memory that I got online? Would I just have to download the image locally and load it?