vertices.clear();
normals.clear();
+ tex_coords.clear();
+ indices.clear();
}
void MeshGL::draw() const
{
if(!vdata_valid) {
- ((MeshGL*)this)->update_vertex_data();
+ ((MeshGL *)this)->update_vertex_data();
}
glBindVertexArray(vao);
glGenBuffers(1, &nvbo);
glBindBuffer(GL_ARRAY_BUFFER, nvbo);
-
+
glBufferData(GL_ARRAY_BUFFER, normals.size() * sizeof(Vec3) * 2, 0, GL_STATIC_DRAW);
Vec3 *data = (Vec3 *)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
- for (size_t i = 0; i < normals.size(); i++)
- {
+ for(size_t i = 0; i < normals.size(); i++) {
*data++ = vertices[i];
*data++ = vertices[i] + normals[i] * scale;
}
glVertexAttribPointer(MESH_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vec3), 0);
glEnableVertexAttribArray(MESH_VERTEX);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- } else {
+ }
+ else {
glBindVertexArray(nvao);
}
glBindVertexArray(0);
}
-void MeshGL::update_vertex_data()
+bool MeshGL::update_vertex_data()
{
update_vbo();
+ return true;
}
void MeshGL::update_vbo()
glDeleteBuffers(1, &vbo_tex_coords);
if(ibo)
glDeleteBuffers(1, &ibo);
- if (vao)
+ if(vao)
glDeleteVertexArrays(1, &vao);
if(nvbo)
glDeleteBuffers(1, &nvbo);
if(nvao)
glDeleteVertexArrays(1, &nvao);
-}
\ No newline at end of file
+}