package speiger.src.coreengine.platform.graphics.api.texture.states;

public enum TextureFormat {
	R(1, 0, -1, -1, -1),
	RG(2, 0, 1, -1, -1),
	RGB(3, 0, 1, 2, -1),
	RGBA(4, 0, 1, 2, 3),
	DEPTH(1, 0, -1, -1, -1),
	DEPTH_STENCIL(2, 0, 1, -1, -1),
	LUMINANCE(1, 0, 0, 0, 0),
	LUMINANCE_ALPHA(2, 0, -1, -1, 1);
	
	int components;
	int componentMask;
	int redOffset;
	int greenOffset;
	int blueOffset;
	int alphaOffset;
	
	private TextureFormat(int components, int redOffset, int greenOffset, int blueOffset, int alphaOffset) {
		this.components = components;
		this.componentMask = (1 << (components * 8)) - 1;
		this.redOffset = redOffset;
		this.greenOffset = greenOffset;
		this.blueOffset = blueOffset;
		this.alphaOffset = alphaOffset;
	}
	
	public int components() { return components; }
	public int componentMask() { return componentMask; }
	public int redOffset() { return redOffset; }
	public int greenOffset() { return greenOffset; }
	public int blueOffset() { return blueOffset; }
	public int alphaOffset() { return alphaOffset; }
	
	public boolean hasRed() { return redOffset != -1; }
	public boolean hasGreen() { return greenOffset != -1; }
	public boolean hasBlue() { return blueOffset != -1; }
	public boolean hasAlpha() { return alphaOffset != -1; }
}
