# Adding vbos to a vao once it has been created

Is it possible to add vbos to vbos after their creation? For example (pseudo-code):

glGenVertexArrays(1, &_vao);
glBindVertexArray(_vao);
// do init stuff
glBindVertexArray(0);

// Much much later in a galaxy far away
glBindVertexArray(_vao);
glGenBuffers(1, &_instance_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _instance_vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(blee), blee, GL_STATIC_DRAW);
glEnableVertexAttribArray(_vpos_att);
glVertexAttribPointer(_vpos_att, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);

// Draw


So far it hasn't really worked. Looking at the bound vbos to my vao (using GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING) shows no buffers bound. Though that may be another problem altogether.

So after debugging some more, I've found that yes it is possible. You cam add buffers later on but they will need to point to their own attributes.

My issues came from thinking I could have multiple vbos contributing to a single attribute. That doesn't work. You need multiple vaos for that scenario.

• What do you mean with "multiple vbos contributing to a single attribute"? This does never work, even with multiple VAOs this wouldn't work. A single attribute can only ever be sourced from a single VBO. So it seems you mean something different when you say "contributing to a single attribute". If you mean sourcing different attributes from different VBOs, this is very much possible, even with just a single VAO. – Christian Rau Apr 9 at 9:37