package client.renderer.texture;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;

import client.util.FileUtils;

public class SimpleTexture extends Texture {
	private final String location;

	public SimpleTexture(String location) {
		this.location = location;
	}

	public void loadTexture() throws IOException {
		this.deleteGlTexture();
		InputStream in = null;
		try {
			in = // this.location.startsWith("/") ? SimpleTexture.class.getResourceAsStream(this.location) : 
				FileUtils.getResource(this.location);
//			if(in == null)
//				throw new FileNotFoundException(this.location);
			BufferedImage img = TextureUtil.readImage(in);
			TextureUtil.uploadImage(this.getGlTextureId(), img);
		}
		finally {
			if(in != null)
				in.close();
		}
	}
}
