fill out LogoBox::draw(), rendering logos with shaders now
This commit is contained in:
parent
4cfa0893f6
commit
d556ef69bf
@ -93,10 +93,45 @@ bool LogoBox::loadShaders()
|
|||||||
glUniform4f(diffuse_loc, 1.0, 0.6, 0.0, 1.0);
|
glUniform4f(diffuse_loc, 1.0, 0.6, 0.0, 1.0);
|
||||||
glUniform4f(specular_loc, 1.0, 1.0, 1.0, 1.0);
|
glUniform4f(specular_loc, 1.0, 1.0, 1.0, 1.0);
|
||||||
glUniform1f(shininess_loc, 85.0);
|
glUniform1f(shininess_loc, 85.0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void renderMaterial(const WFObj::Material & m)
|
||||||
|
{
|
||||||
|
if (m.flags & WFObj::Material::SHININESS_BIT)
|
||||||
|
glUniform1f(shininess_loc, m.shininess);
|
||||||
|
if (m.flags & WFObj::Material::AMBIENT_BIT)
|
||||||
|
glUniform4fv(ambient_loc, 1, &m.ambient[0]);
|
||||||
|
if (m.flags & WFObj::Material::DIFFUSE_BIT)
|
||||||
|
glUniform4fv(diffuse_loc, 1, &m.diffuse[0]);
|
||||||
|
if (m.flags & WFObj::Material::SPECULAR_BIT)
|
||||||
|
glUniform4fv(specular_loc, 1, &m.specular[0]);
|
||||||
|
if (m.flags & WFObj::Material::TEXTURE_BIT)
|
||||||
|
{
|
||||||
|
cerr << "error: textured materials not implemented yet" << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogoBox::draw()
|
void LogoBox::draw()
|
||||||
{
|
{
|
||||||
if (!loaded)
|
if (!loaded)
|
||||||
return;
|
return;
|
||||||
|
obj.bindBuffers();
|
||||||
|
glUseProgram(program);
|
||||||
|
glEnableVertexAttribArray(LOC_POSITION);
|
||||||
|
glEnableVertexAttribArray(LOC_NORMAL);
|
||||||
|
int stride = obj.getStride();
|
||||||
|
glVertexAttribPointer(LOC_POSITION, 3, GL_FLOAT, GL_FALSE,
|
||||||
|
stride, (GLvoid *) obj.getVertexOffset());
|
||||||
|
glVertexAttribPointer(LOC_NORMAL, 3, GL_FLOAT, GL_FALSE,
|
||||||
|
stride, (GLvoid *) obj.getNormalOffset());
|
||||||
|
for (map<string, WFObj::Material>::iterator it = obj.getMaterials().begin();
|
||||||
|
it != obj.getMaterials().end();
|
||||||
|
it++)
|
||||||
|
{
|
||||||
|
renderMaterial(it->second);
|
||||||
|
glDrawElements(GL_TRIANGLES, it->second.num_vertices,
|
||||||
|
GL_UNSIGNED_SHORT,
|
||||||
|
(GLvoid *) (sizeof(GLushort) * it->second.first_vertex));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user