package ca.blarg.gdx.graphics.shaders;

import com.badlogic.gdx.graphics.glutils.ShaderProgram;

public class SimpleColorTextureShaderProgram extends ShaderProgram {
	public static final String VERTEX_SHADER =
			"attribute vec4 " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" +
			"attribute vec4 " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" +
			"attribute vec2 " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" +
			"uniform mat4 u_projectionViewMatrix;\n" +
			"varying vec4 v_color;\n" +
			"varying vec2 v_texCoords;\n" +
			"\n" +
			"void main()\n" +
			"{\n" +
			"	v_color = " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" +
			"	v_texCoords = " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" +
			"	gl_Position =  u_projectionViewMatrix * " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" +
			"}\n";

	public static final String FRAGMENT_SHADER =
			"#ifdef GL_ES\n" +
			"	#define LOWP lowp\n" +
			"	precision mediump float;\n" +
			"#else\n" +
			"	#define LOWP\n" +
			"#endif\n" +
			"varying LOWP vec4 v_color;\n" +
			"varying vec2 v_texCoords;\n" +
			"uniform sampler2D u_texture;\n" +
			"\n" +
			"void main()\n" +
			"{\n" +
			"	gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n" +
			"}\n";

	public SimpleColorTextureShaderProgram() {
		super(VERTEX_SHADER, FRAGMENT_SHADER);
	}
}
