build flat_vertices collection for VBO

This commit is contained in:
Josh Holtrop 2011-04-24 19:14:07 -04:00
parent 67ef0c4009
commit 6dab4e48a6
2 changed files with 18 additions and 2 deletions

View File

@ -442,12 +442,28 @@ bool WFObj::loadfile(const char *path, Buffer & buff)
void WFObj::buildVBO()
{
map<VertexRef, int> flat_vertices;
int vid = 0;
glGenBuffers(1, &m_vbo);
bool do_textures = m_loadtexture != NULL
&& m_vertices[VERTEX_TEXTURE].size() > 0;
for (map<string, vector<Face> >::iterator it = m_faces.begin();
it != m_faces.end();
it++)
{
for (vector<Face>::iterator fit = it->second.begin();
fit != it->second.end();
fit++)
{
for (int i = 0; i < 3; i++)
{
flat_vertices[fit->vertices[i]] = vid++;
}
}
}
}
bool WFObj::VertexRef::operator<(const VertexRef & other)
bool WFObj::VertexRef::operator<(const VertexRef & other) const
{
if (vertex != other.vertex)
return vertex < other.vertex;

View File

@ -61,7 +61,7 @@ protected:
int vertex;
int texture;
int normal;
bool operator<(const VertexRef & other);
bool operator<(const VertexRef & other) const;
};
class Face