For sake of simplicity say I have a cube made of 12 triangles and I want it to rotate. The method I am using atm is:
float triangles[108] = {...values...}; // 12 triangles * 3 vertices * 3 floats per vertex
.
.
while (somecondition)
{
int matrix[9] = get_matrix();
GLuint buffer;
glGenBuffers(1, &buffer);
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat), 108, triangles, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glUniformMatrix3fv(uniform_id, 1, GL_FALSE, matrix);
glDrawArrays(GL_TRIANGLES, 0, 36);
glDisableVertexAttribArray(0);
}
I realize I am sending the same 108 floats to opengl every frame, when all I really want is to update the uniform matrix.
How do I do this?