inlined renderMaterial()
This commit is contained in:
parent
f0e4bbd3b1
commit
5f55756a08
@ -32,7 +32,6 @@ private:
|
|||||||
void initgl();
|
void initgl();
|
||||||
void display();
|
void display();
|
||||||
void setProjection();
|
void setProjection();
|
||||||
void renderMaterial(const WFObj::Material & m);
|
|
||||||
|
|
||||||
WFObj m_obj;
|
WFObj m_obj;
|
||||||
GLuint m_list;
|
GLuint m_list;
|
||||||
@ -275,7 +274,19 @@ void Viewer::display()
|
|||||||
it != m_obj.getMaterials().end();
|
it != m_obj.getMaterials().end();
|
||||||
it++)
|
it++)
|
||||||
{
|
{
|
||||||
renderMaterial(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)
|
||||||
|
{
|
||||||
|
cerr << "error: textured materials not implemented yet" << endl;
|
||||||
|
}
|
||||||
glDrawElements(GL_TRIANGLES, it->second.num_vertices,
|
glDrawElements(GL_TRIANGLES, it->second.num_vertices,
|
||||||
GL_UNSIGNED_SHORT,
|
GL_UNSIGNED_SHORT,
|
||||||
(GLvoid *) (sizeof(GLushort) * it->second.first_vertex));
|
(GLvoid *) (sizeof(GLushort) * it->second.first_vertex));
|
||||||
@ -348,19 +359,3 @@ void Viewer::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::renderMaterial(const WFObj::Material & m)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
cerr << "error: textured materials not implemented yet" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user