use two VBOs, filling in data VBO
This commit is contained in:
parent
0bdfff50e7
commit
02a3f85fc1
14
WFObj.cc
14
WFObj.cc
@ -109,7 +109,10 @@ WFObj::WFObj(loadfile_t lf, loadtexture_t lt)
|
|||||||
m_loadfile = loadfile;
|
m_loadfile = loadfile;
|
||||||
}
|
}
|
||||||
if (m_valid)
|
if (m_valid)
|
||||||
glDeleteBuffers(1, &m_vbo);
|
{
|
||||||
|
glDeleteBuffers(1, &m_data_vbo);
|
||||||
|
glDeleteBuffers(1, &m_index_vbo);
|
||||||
|
}
|
||||||
m_valid = false;
|
m_valid = false;
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
@ -445,7 +448,6 @@ bool WFObj::buildVBO()
|
|||||||
{
|
{
|
||||||
map<VertexRef, int> flat_vertices;
|
map<VertexRef, int> flat_vertices;
|
||||||
int vid = 0, texture_ref_count = 0;
|
int vid = 0, texture_ref_count = 0;
|
||||||
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();
|
for (map<string, vector<Face> >::iterator it = m_faces.begin();
|
||||||
@ -490,7 +492,8 @@ bool WFObj::buildVBO()
|
|||||||
3 + /* vertex coordinates */
|
3 + /* vertex coordinates */
|
||||||
3 + /* normal coordinates */
|
3 + /* normal coordinates */
|
||||||
(do_textures ? 2 : 0); /* texture coordinates */
|
(do_textures ? 2 : 0); /* texture coordinates */
|
||||||
GLfloat * data = new GLfloat[n_floats_per_vref * flat_vertices.size()];
|
size_t n_data_elements = n_floats_per_vref * flat_vertices.size();
|
||||||
|
GLfloat * data = new GLfloat[n_data_elements];
|
||||||
for (map<VertexRef, int>::iterator it = flat_vertices.begin();
|
for (map<VertexRef, int>::iterator it = flat_vertices.begin();
|
||||||
it != flat_vertices.end();
|
it != flat_vertices.end();
|
||||||
it++)
|
it++)
|
||||||
@ -509,6 +512,11 @@ bool WFObj::buildVBO()
|
|||||||
data[base + 7] = m_vertices[VERTEX_TEXTURE][vr.texture - 1][1];
|
data[base + 7] = m_vertices[VERTEX_TEXTURE][vr.texture - 1][1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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,
|
||||||
|
GL_STATIC_DRAW);
|
||||||
delete[] data;
|
delete[] data;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user