implement grid and heightmap with lambert shading

This commit is contained in:
2018-12-24 22:22:16 +01:00
parent 4d2706bfab
commit 52c87d9ec6
16 changed files with 297 additions and 101 deletions

View File

@@ -75,6 +75,9 @@ bool Shader::create(const char* vertex, const char* fragment)
if (glGetAttribLocation(ps, "col") != -1)
glBindAttribLocation(ps, 3, "col");
if (glGetAttribLocation(ps, "nor") != -1)
glBindAttribLocation(ps, 3, "nor");
glLinkProgram(ps);
glGetProgramiv(ps, GL_LINK_STATUS, &status);
glGetProgramInfoLog(ps, sizeof(infolog), &infolen, infolog);
@@ -117,6 +120,12 @@ void Shader::u_vec4(kShaderUniform id, const glm::vec4& v)
LOG("UNIFORM vec4 %d NOT FOUND in shader %d", (int)id, (int)name)
else glUniform4fv(m_umap[id], 1, glm::value_ptr(v));
}
void Shader::u_vec3(kShaderUniform id, const glm::vec3& v)
{
if (m_umap.count(id) == 0)
LOG("UNIFORM vec3 %d NOT FOUND in shader %d", (int)id, (int)name)
else glUniform3fv(m_umap[id], 1, glm::value_ptr(v));
}
void Shader::u_vec2(kShaderUniform id, const glm::vec2& v)
{
@@ -171,6 +180,11 @@ void ShaderManager::u_vec4(kShaderUniform id, const glm::vec4& v)
m_current->u_vec4(id, v);
}
void ShaderManager::u_vec3(kShaderUniform id, const glm::vec3& v)
{
m_current->u_vec3(id, v);
}
void ShaderManager::u_vec2(kShaderUniform id, const glm::vec2& v)
{
m_current->u_vec2(id, v);