#include "client/render/shader/GunShader.h"

namespace blitz {
namespace shader {

static const std::string vertexSource = ShaderProgram::GetShaderHeader() + R"(

layout(location = 0) in vec3 position;
layout(location = 1) in vec2 textureCoords;
layout(location = 2) in vec3 normal;

uniform mat4 projectionMatrix;
uniform mat4 modelMatrix;

out vec2 pass_textureCoords;
out vec4 pos;

void main(void){
	pos = projectionMatrix * modelMatrix * vec4(position, 1.0);
	gl_Position = pos;

	pass_textureCoords = textureCoords;
}
)";

static const std::string fragmentSource = ShaderProgram::GetShaderHeader() + R"(

uniform sampler2D textureSampler;

in vec2 pass_textureCoords;
in vec4 pos;

out vec4 out_color;

void main(void){

	out_color = pos;
	out_color.w = 1.0;
	// out_color = gl_Position + vec4(0.5, 0.5, 0.5, 0);
	// out_color = texture(textureSampler, pass_textureCoords);

}
)";

GunShader::GunShader() : ShaderProgram() {}

bool GunShader::LoadShader() {
	return ShaderProgram::LoadProgram(vertexSource, fragmentSource);
}

void GunShader::GetAllUniformLocation() {
	m_LocationProjection = static_cast<unsigned int>(GetUniformLocation("projectionMatrix"));
	m_LocationTransform = static_cast<unsigned int>(GetUniformLocation("modelMatrix"));
}

void GunShader::SetProjectionMatrix(const Mat4f& proj) const {
	LoadMat4(m_LocationProjection, proj);
}

void GunShader::SetModelTransform(const Mat4f& trans) const {
	LoadMat4(m_LocationTransform, trans);
}

}  // namespace shader
}  // namespace blitz