package speiger.src.coreengine.rendering.textures.base;

import java.io.Closeable;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.function.Consumer;

import org.lwjgl.system.MemoryUtil;

import speiger.src.coreengine.assets.IAssetParser;

public class NativeMemoryParser implements IAssetParser<ByteBuffer>
{

	@Override
	public ByteBuffer parseAsset(Path path, Consumer<Closeable> autoCloser) throws IOException
	{
		byte[] data = Files.readAllBytes(path);
		ByteBuffer buffer = MemoryUtil.memAlloc(data.length);
		buffer.put(data);
		buffer.flip();
		return buffer;
	}
	
}
