
package speiger.src.coreengine.rendering.guiOld.renderer;

import speiger.src.coreengine.assets.AssetLocation;
import speiger.src.coreengine.math.vector.matrix.Matrix4f;
import speiger.src.coreengine.rendering.models.buffers.UniformBuffer;
import speiger.src.coreengine.rendering.shaderOld.ShaderProgram;
import speiger.src.coreengine.rendering.shaderOld.uniforms.UniformBufferBlock;
import speiger.src.coreengine.rendering.shaderOld.uniforms.UniformFloat;
import speiger.src.coreengine.rendering.shaderOld.uniforms.UniformMatrix;
import speiger.src.coreengine.rendering.shaderOld.uniforms.UniformTexture;
import speiger.src.coreengine.rendering.shaderOld.uniforms.UniformVec4f;

public class GuiShader extends ShaderProgram
{
	public UniformBufferBlock proViewMatrix = new UniformBufferBlock("cameraTransform", 1);
	public UniformMatrix modelMatrix = new UniformMatrix("modelMatrix");
	public UniformTexture texture = new UniformTexture("texture", 0);
	public UniformFloat useTexture = new UniformFloat("use_texture");
	public UniformFloat roundeness = new UniformFloat("roundness");
	public UniformVec4f bounds = new UniformVec4f("bounds");
	
	public GuiShader(AssetLocation vertex, AssetLocation fragment, String...args)
	{
		super(vertex, fragment, args);
		addUniforms(proViewMatrix, modelMatrix, texture, useTexture, roundeness, bounds);
	}
	
	public static GuiShader create()
	{
		return new GuiShader(AssetLocation.of("shader/gui/guiVertex.txt"), AssetLocation.of("shader/gui/guiFragment.txt"), "in_position", "in_tex", "in_color");
	}
	
	public void bind(UniformBuffer view)
	{
		if(isShaderRunning()) return;
		startShader();
		proViewMatrix.bindBuffer(view);
	}
	
	@Override
	public GuiShader init()
	{
		startShader();
		modelMatrix.storeData(new Matrix4f());
		bounds.storeData(0F, 0F, 0F, 0F);
		stopShader();
		return this;
	}
}