I'm having trouble understanding how to actually translate a single object contained in a vbo. So first I set up vao and vbo and bind and enter vertices of a cube...
glGenVertexArrays(1, &_vertexArray1); //Bind to first VAO
glBindVertexArray(_vertexArray1);
glGenBuffers(1, &_vertexBufferCube1);
glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferCube1);
glBufferData(GL_ARRAY_BUFFER, g_point_count * 3 * sizeof (float), &g_vp[0], GL_STATIC_DRAW);
glEnableVertexAttribArray(loc1);
glVertexAttribPointer(loc1, 3, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(loc2);
glVertexAttribPointer(loc2, 3, GL_FLOAT, GL_FALSE, 0, NULL);`
Then in my display function...
// tell GL to only draw onto a pixel if the shape is closer to the viewer
glEnable (GL_DEPTH_TEST); // enable depth-testing
glDepthFunc (GL_LESS); // depth-testing interprets a smaller value as "closer"
glClearColor (0.5f, 0.5f, 0.5f, 1.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram (shaderProgramID);
//Declare your uniform variables that will be used in your shader
int matrix_location = glGetUniformLocation (shaderProgramID, "model");
int view_mat_location = glGetUniformLocation (shaderProgramID, "view");
int proj_mat_location = glGetUniformLocation (shaderProgramID, "proj");
mat4 view = identity_mat4 ();
mat4 persp_proj = perspective(45.0, (float)width/(float)height, 0.1, 100.0);
mat4 model = identity_mat4 ();
view = translate (view, vec3 (0.0, 0.0, -5.0f));
glUniformMatrix4fv (proj_mat_location, 1, GL_FALSE, persp_proj.m);
glUniformMatrix4fv (view_mat_location, 1, GL_FALSE, view.m);
glUniformMatrix4fv (matrix_location, 1, GL_FALSE, model.m);
glBindVertexArray(_vertexArray1);
//model = translate (view, vec3 (0.0, -3.0F, 0.0));
glDrawArrays (GL_TRIANGLES, 0, g_point_count);
glBindVertexArray(0);
Now my issue is that I want to move the object in one vao independently of another. How should I be doing this? Should I just be translating the model matrix then unbind the vao and bind another one and translate the same model matrix again? After googling for a good while I think I should be using glPushMatrix and glTranslatef but what matrix do I push?
Essentially where is the matrix for my vao that needs to be translated in order to move the object in the vao?