Compare commits
3
Commits
a12c4ec42d
...
2e599ab86b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e599ab86b | ||
|
|
e1f2d5a04a | ||
|
|
ce0a8e608d |
@@ -518,7 +518,6 @@ bool WFObj::buildVBO()
|
||||
it++)
|
||||
{
|
||||
int first = vid;
|
||||
int num = 0;
|
||||
for (vector<Face>::iterator fit = it->second.begin();
|
||||
fit != it->second.end();
|
||||
fit++)
|
||||
@@ -527,18 +526,19 @@ bool WFObj::buildVBO()
|
||||
{
|
||||
VertexRef vf = fit->vertices[i];
|
||||
indices[vid] = flat_vertices[vf];
|
||||
num++;
|
||||
vid++;
|
||||
}
|
||||
}
|
||||
m_face_indices[it->first] = make_pair(first, num);
|
||||
m_face_indices[it->first] = make_pair(first, vid - first);
|
||||
}
|
||||
glGenBuffers(1, &m_data_vbo);
|
||||
glGenBuffers(1, &m_index_vbo);
|
||||
/* move data from client side to GL */
|
||||
glBufferData(m_data_vbo, sizeof(GLfloat) * n_data_elements, data,
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_data_vbo);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_index_vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n_data_elements, data,
|
||||
GL_STATIC_DRAW);
|
||||
glBufferData(m_index_vbo, sizeof(GLshort) * n_vrefs, indices,
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLshort) * n_vrefs, indices,
|
||||
GL_STATIC_DRAW);
|
||||
delete[] data;
|
||||
delete[] indices;
|
||||
@@ -571,7 +571,7 @@ void WFObj::draw()
|
||||
renderMaterial(m_materials[it->first]);
|
||||
glDrawElements(GL_TRIANGLES, m_face_indices[it->first].second,
|
||||
GL_UNSIGNED_SHORT,
|
||||
(GLvoid *) (sizeof(GLfloat) * m_face_indices[it->first].first));
|
||||
(GLvoid *) (sizeof(GLshort) * m_face_indices[it->first].first));
|
||||
glPopAttrib();
|
||||
}
|
||||
glPopClientAttrib();
|
||||
|
||||
Reference in new issue
Block a user