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

public enum GraphicsDataType {
	BYTE("byte", 1, PrimitiveType.BYTE),
	UNSIGNED_BYTE("u_byte", 1, PrimitiveType.BYTE, true),
	SHORT("short", 2, PrimitiveType.SHORT),
	UNSIGNED_SHORT("u_short", 2, PrimitiveType.SHORT, true),
	INT("int", 4, PrimitiveType.INT),
	UNSIGNED_INT("u_int", 4, PrimitiveType.INT, true),
	FLOAT("float", 4, PrimitiveType.FLOAT),
	DOUBLE("double", 8, PrimitiveType.DOUBLE),
	
	//CompressedTypes
	UNSIGNED_3_3_2("u_byte_3_3_2", 1, PrimitiveType.BYTE, false, true),
	UNSIGNED_2_3_3_REV("u_byte_2_3_3_rev", 1, PrimitiveType.BYTE, false, true),
	UNSIGNED_5_6_5("u_short_5_6_5", 2, PrimitiveType.SHORT, false, true),
	UNSIGNED_5_6_5_REV("u_short_5_6_5_rev", 2, PrimitiveType.SHORT, false, true),
	UNSIGNED_4_4_4_4("u_short_4_4_4_4", 2, PrimitiveType.SHORT, false, true),
	UNSIGNED_4_4_4_4_REV("u_short_4_4_4_4_rev", 2, PrimitiveType.SHORT, false, true),
	UNSIGNED_5_5_5_1("u_short_5_5_5_1", 2, PrimitiveType.SHORT, false, true),
	UNSIGNED_1_5_5_5_REV("u_short_1_5_5_5_rev", 2, PrimitiveType.SHORT, false, true),
	UNSIGNED_8_8_8_8("u_int_8_8_8_8", 4, PrimitiveType.INT, false, true),
	UNSIGNED_8_8_8_8_REV("u_int_8_8_8_8_rev", 4, PrimitiveType.INT, false, true),
	UNSIGNED_10_10_10_2("u_int_10_10_10_2", 4, PrimitiveType.INT, false, true),
	UNSIGNED_2_10_10_10_REV("u_int_2_10_10_10_rev", 4, PrimitiveType.INT, false, true),
	
	UNSIGNED_INT_10F_11F_11F_REV("u_int_10_11_11_rev", 4, PrimitiveType.INT, false, true),
	UNSIGNED_INT_5_9_9_9_REV("u_int_5_9_9_9_rev", 4, PrimitiveType.INT, false, true);
	
	String name;
	int byteSize;
	PrimitiveType type;
	boolean supportsIBO;
	boolean compound;
	
	private GraphicsDataType(String name, int byteSize, PrimitiveType type, boolean supportsIBO, boolean compound) {
		this.name = name;
		this.byteSize = byteSize;
		this.type = type;
		this.supportsIBO = supportsIBO;
		this.compound = compound;
	}
	
	private GraphicsDataType(String name, int byteSize, PrimitiveType type, boolean supportsIBO) {
		this(name, byteSize, type, supportsIBO, false);
	}

	
	private GraphicsDataType(String name, int byteSize, PrimitiveType type) {
		this(name, byteSize, type, false, false);
	}
	
	public String idName() {
		return name;
	}
	
	public int byteSize() {
		return byteSize;
	}
	
	public PrimitiveType type() {
		return type;
	}
	
	public boolean isCompound() {
		return compound;
	}
	
	public boolean supportsIBO() {
		return supportsIBO; 
	}
	
	public int size(int attributes) {
		return compound ? byteSize : attributes * byteSize; 
	}
	
}
