Re-added VAO code to mesh building, hopefully to no error.

master
kts 2015-02-13 15:12:26 -08:00
parent f8758111dc
commit 8b11fd78f3
1 changed files with 5 additions and 0 deletions

View File

@ -211,10 +211,15 @@ int Mesh::loadArrays(Vec3 *in_vertices, int v_count, Vec2 *in_uvs, int uv_count,
int Mesh::buildMesh() {
if (!(flags & MESH_LOADED)) return 1;
if (flags & MESH_BUILT) destroyMesh();
// generate our vertex array object
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
// generate our vertex buffer object from our given points
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, vertices.size()*sizeof(Vec3), &vertices[0], mode);
// unbind vao to disallow external mucking
glBindVertexArray(0);
flags |= MESH_BUILT;
return 0;
}