there is NO order in which you have to setup your vertex array object
you dont have to “re-link” anything after updating a buffer content
you setup your vertex array just once, when done, you just draw like you’ve described:
useProgram(program);
bind(VAO);
drawArrays(…);
unbind(VAO); // bind(0)
unbind(program); // useProgram(0)
post your code to get more precise infos …
GL_INVALID_ENUM means you are giving wrong argument(s) to a gl-call
for you setup procedure:
–> the state of vertex attributes (enabled/disabled) is also stored in the VAO, so you have to do that for each VAO, not once (before binding any VAO)
–> the same is true for te vertex attrib pointers:
example:
glBindVertexarray(VAO1);
// use buffer VBO1 for vertex position
glBindBuffer(GL_ARRAY_BUFFER, VBO1);
glVertexAttribPointer(index1, 3, GL_FLOAT, false, ...);
// use buffer VBO2 for vertex texture coordinates
glBindBuffer(GL_ARRAY_BUFFER, VBO2);
glVertexAttribPointer(index2, 2, GL_FLOAT, false, ...);
// use buffer VBO3 for vertex normals
glBindBuffer(GL_ARRAY_BUFFER, VBO3);
glVertexAttribPointer(index3, 3, GL_FLOAT, false, ...);
// use buffer VBO4 for vertex color (if needed)
glBindBuffer(GL_ARRAY_BUFFER, VBO4);
glVertexAttribPointer(index4, 4, GL_FLOAT, false, ...);
// use buffer VBO5 for model instances (if needed)
glBindBuffer(GL_ARRAY_BUFFER, VBO5);
glVertexAttribPointer(index5, ...);
// finished, unbind buffer
glBindBuffer(GL_ARRAY_BUFFER, 0);
// now enable attributes:
glEnableVertexAttribArray(index1);
glEnableVertexAttribArray(index2);
glEnableVertexAttribArray(index3);
glEnableVertexAttribArray(index4);
glEnableVertexAttribArray(index5);
// then set some divisors (if needed)
glVertexAttribDivisor(index5, 1);// if you call glDrawArraysInstanced(...) and want this attribute once per instance
glBindVertexarray(0);
// do the same for VAO2
// you can allocate buffer memory and set the content independent from this setup
// you have to set 4 attributes for each 4x4 matrix buffer