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

public enum DrawMode {
	POINT(1),
	LINES(2),
	LINE_STRIP(2, true),
	LINE_LOOP(2, true),
	TRIANGLES(3),
	TRIANGLE_STRIP(3, true),
	TRIANGLE_FAN(3, true),
	QUADS(4);
	
	int length;
	boolean isConnective;
	
	private DrawMode(int length) {
		this(length, false);
	}
	
	private DrawMode(int length, boolean isConnective) {
		this.length = length;
		this.isConnective = isConnective;
	}
	
	public int primitiveLength() { return length; }
	public boolean isConnective() { return isConnective; }
	public int indeciesCount(int vertecies) {
		return switch(this) {
			case POINT, LINE_STRIP, TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN -> vertecies;
			case LINES, QUADS -> vertecies / 4 * 6;
			default -> 0;
		};
	}
}
