pass uniforms to texture program correctly
This commit is contained in:
parent
e12a86f858
commit
ab56320889
@ -205,14 +205,6 @@ void Viewer::display()
|
|||||||
it++)
|
it++)
|
||||||
{
|
{
|
||||||
WFObj::Material & m = it->second;
|
WFObj::Material & m = it->second;
|
||||||
if (m.flags & WFObj::Material::SHININESS_BIT)
|
|
||||||
glUniform1f(m_shininess_loc, m.shininess);
|
|
||||||
if (m.flags & WFObj::Material::AMBIENT_BIT)
|
|
||||||
glUniform4fv(m_ambient_loc, 1, &m.ambient[0]);
|
|
||||||
if (m.flags & WFObj::Material::DIFFUSE_BIT)
|
|
||||||
glUniform4fv(m_diffuse_loc, 1, &m.diffuse[0]);
|
|
||||||
if (m.flags & WFObj::Material::SPECULAR_BIT)
|
|
||||||
glUniform4fv(m_specular_loc, 1, &m.specular[0]);
|
|
||||||
if (m.flags & WFObj::Material::TEXTURE_BIT)
|
if (m.flags & WFObj::Material::TEXTURE_BIT)
|
||||||
{
|
{
|
||||||
if (program != m_tex_program)
|
if (program != m_tex_program)
|
||||||
@ -231,6 +223,32 @@ void Viewer::display()
|
|||||||
glDisableVertexAttribArray(LOC_TEXTURE);
|
glDisableVertexAttribArray(LOC_TEXTURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (m.flags & WFObj::Material::SHININESS_BIT)
|
||||||
|
{
|
||||||
|
if (program == m_tex_program)
|
||||||
|
glUniform1f(m_tex_shininess_loc, m.shininess);
|
||||||
|
else
|
||||||
|
glUniform1f(m_shininess_loc, m.shininess);
|
||||||
|
}
|
||||||
|
if (m.flags & WFObj::Material::AMBIENT_BIT)
|
||||||
|
{
|
||||||
|
if (program == m_tex_program)
|
||||||
|
glUniform4fv(m_tex_ambient_loc, 1, &m.ambient[0]);
|
||||||
|
else
|
||||||
|
glUniform4fv(m_ambient_loc, 1, &m.ambient[0]);
|
||||||
|
}
|
||||||
|
if (m.flags & WFObj::Material::DIFFUSE_BIT)
|
||||||
|
{
|
||||||
|
if (program != m_tex_program)
|
||||||
|
glUniform4fv(m_diffuse_loc, 1, &m.diffuse[0]);
|
||||||
|
}
|
||||||
|
if (m.flags & WFObj::Material::SPECULAR_BIT)
|
||||||
|
{
|
||||||
|
if (program == m_tex_program)
|
||||||
|
glUniform4fv(m_tex_specular_loc, 1, &m.specular[0]);
|
||||||
|
else
|
||||||
|
glUniform4fv(m_specular_loc, 1, &m.specular[0]);
|
||||||
|
}
|
||||||
glDrawElements(GL_TRIANGLES, m.num_vertices,
|
glDrawElements(GL_TRIANGLES, m.num_vertices,
|
||||||
GL_UNSIGNED_SHORT,
|
GL_UNSIGNED_SHORT,
|
||||||
(GLvoid *) (sizeof(GLushort) * m.first_vertex));
|
(GLvoid *) (sizeof(GLushort) * m.first_vertex));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user