package speiger.src.coreengine.rendering.utils.states;

import org.lwjgl.opengl.GL11;

import speiger.src.coreengine.rendering.utils.values.GLCullType;

public class CullState extends GLState {
	GLCullType defaultValue;
	GLCullType state;
	
	public CullState(GLCullType defaultState) {
		super(GL11.GL_CULL_FACE, false);
		defaultValue = state = defaultState;
	}
	
	public CullState enable(GLCullType state) {
		enable();
		if(this.state != state) {
			this.state = state;
			GL11.glCullFace(state.glValue());
		}
		return this;
	}
	
	public GLCullType get() {
		return state;
	}
	
	@Override
	public void reapply() {
		super.reapply();
		GL11.glCullFace(state.glValue());
	}
	
	@Override
	public void setDefault() {
		enable(defaultValue);
		super.setDefault();		
	}
}
