package speiger.src.coreengine.rendering.shaderOld.uniforms;

import org.lwjgl.opengl.GL20;

import speiger.src.coreengine.math.vector.matrix.Matrix4f;
import speiger.src.coreengine.rendering.utils.AllocationTracker;

public class UniformMatrix extends UniformBase<Matrix4f> {
	public UniformMatrix(String id) {
		super(id);
	}

	public void storeData(Matrix4f data) {
		if (hasChanged(data)) {
			GL20.glUniformMatrix4fv(getPosition(), false, data.getData());
			AllocationTracker.INSTANCE.addGPUBytes(64L);
		}
	}

	@Override
	protected Matrix4f setValue(Matrix4f oldValue, Matrix4f newValue) {
		if (oldValue != null) {
			return oldValue.load(newValue);
		}
		return new Matrix4f(newValue);
	}
}
