build flat_vertices collection for VBO

This commit is contained in:
Josh Holtrop committed 2011-04-24 19:14:07 -04:00
1 parent 67ef0c4009
commit 6dab4e48a6
2 files changed
+18 -2

No files matched your search

+17 -1
View File
@@ -442,12 +442,28 @@ bool WFObj::loadfile(const char *path, Buffer & buff)
void WFObj::buildVBO() void WFObj::buildVBO()
{ {
map<VertexRef, int> flat_vertices;
int vid = 0;
glGenBuffers(1, &m_vbo); glGenBuffers(1, &m_vbo);
bool do_textures = m_loadtexture != NULL bool do_textures = m_loadtexture != NULL
&& m_vertices[VERTEX_TEXTURE].size() > 0; && 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) if (vertex != other.vertex)
return vertex < other.vertex; return vertex < other.vertex;
+1 -1
View File
@@ -61,7 +61,7 @@ protected:
int vertex; int vertex;
int texture; int texture;
int normal; int normal;
bool operator<(const VertexRef & other); bool operator<(const VertexRef & other) const;
}; };
class Face class Face