Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
#include <fstream>

Shader::Shader(const std::string& fileName)
{
{
m_program = glCreateProgram();
m_shaders[0] = CreateShader(LoadShader(fileName + ".vs"), GL_VERTEX_SHADER);
m_shaders[1] = CreateShader(LoadShader(fileName + ".fs"), GL_FRAGMENT_SHADER);

for(unsigned int i = 0; i < NUM_SHADERS; i++)
glAttachShader(m_program, m_shaders[i]);

glBindAttribLocation(m_program, 0, "position");
glBindAttribLocation(m_program, 1, "texCoord");
glBindAttribLocation(m_program, 2, "normal");
glBindAttribLocation(m_program, 0, "position");
glBindAttribLocation(m_program, 1, "texCoord");
glBindAttribLocation(m_program, 2, "normal");

glLinkProgram(m_program);
CheckShaderError(m_program, GL_LINK_STATUS, true, "Error linking shader program");

glValidateProgram(m_program);
CheckShaderError(m_program, GL_LINK_STATUS, true, "Invalid shader program");
CheckShaderError(m_program, GL_VALIDATE_STATUS, true, "Invalid shader program");

m_uniforms[0] = glGetUniformLocation(m_program, "MVP");
m_uniforms[1] = glGetUniformLocation(m_program, "Normal");
Expand Down Expand Up @@ -115,4 +115,4 @@ GLuint Shader::CreateShader(const std::string& text, unsigned int type)
CheckShaderError(shader, GL_COMPILE_STATUS, false, "Error compiling shader!");

return shader;
}
}