package speiger.src.coreengine.rendering.shader.uniform.base;

import org.lwjgl.opengl.GL41;

import speiger.src.coreengine.rendering.shader.uniform.Uniform;
import speiger.src.coreengine.rendering.utils.AllocationTracker;

public class BoolUniform extends Uniform {
	boolean value;
	
	public BoolUniform(String name, boolean value) {
		super(name);
		this.value = value;
	}
	
	public BoolUniform set(boolean value) {
		if(this.value != value) {
			this.value = value;
			update();
		}
		return this;
	}
	
	@Override
	protected void processChanges(int programId, int location) {
		GL41.glProgramUniform1f(programId, location, value ? 1F : 0F);
		AllocationTracker.INSTANCE.addGPUBytes(1L);
	}
}
