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 TextureUniform extends Uniform {
	int unit;
	
	public TextureUniform(String name, int unit) {
		super(name);
		this.unit = unit;
	}
	
	public TextureUniform set(int unit) {
		if(this.unit != unit) {
			this.unit = unit;
			update();
		}
		return this;
	}
	
	@Override
	protected void processChanges(int programId, int location) {
		GL41.glProgramUniform1i(programId, location, unit);
		AllocationTracker.INSTANCE.addGPUBytes(4L);
	}
}
