fill in client-side data

This commit is contained in:
Josh Holtrop 2011-04-24 22:19:24 -04:00
parent 5eed1256ef
commit d13e3a60b2

View File

@ -472,7 +472,8 @@ bool WFObj::buildVBO()
}
if (vf.texture != 0)
texture_ref_count++;
flat_vertices[vf] = vid++;
if (flat_vertices.find(vf) == flat_vertices.end())
flat_vertices[vf] = vid++;
}
}
}
@ -480,9 +481,27 @@ bool WFObj::buildVBO()
do_textures = false;
size_t n_floats_per_vref =
3 + /* vertex coordinates */
(do_textures ? 2 : 0) + /* texture coordinates */
3; /* normal coordinates */
3 + /* normal coordinates */
(do_textures ? 2 : 0); /* texture coordinates */
GLfloat * data = new GLfloat[n_floats_per_vref * flat_vertices.size()];
for (map<VertexRef, int>::iterator it = flat_vertices.begin();
it != flat_vertices.end();
it++)
{
int base = n_floats_per_vref * it->second;
VertexRef vr = it->first;
data[base + 0] = m_vertices[VERTEX][vr.vertex - 1][0];
data[base + 1] = m_vertices[VERTEX][vr.vertex - 1][1];
data[base + 2] = m_vertices[VERTEX][vr.vertex - 1][2];
data[base + 3] = m_vertices[VERTEX_NORMAL][vr.normal - 1][0];
data[base + 4] = m_vertices[VERTEX_NORMAL][vr.normal - 1][1];
data[base + 5] = m_vertices[VERTEX_NORMAL][vr.normal - 1][2];
if (do_textures && vr.texture > 0)
{
data[base + 6] = m_vertices[VERTEX_TEXTURE][vr.texture - 1][0];
data[base + 7] = m_vertices[VERTEX_TEXTURE][vr.texture - 1][1];
}
}
delete[] data;
return true;
}