我正在使用Modern OpenGL(版本2.1+)。它与经典版本有很多不同之处。所有都是缓冲区,顶点缓冲区,元素缓冲区,统一缓冲区,以及做旧事情的经典方法已被弃用: - | ...
我的问题:现代opengl中“移动”(无论如何,转换为gereral)的最佳方法是什么?
目前,我这样做:
void render()
{
glUseProgram(hProg);
...
modelMatrix = glm::mat4(1.0f); // like glLoadIdentity()
glUniformMatrix4fv(uni_modelMatrix, 1, GL_FALSE, glm::value_ptr(modelMatrix));
glBindBuffer(GL_ARRAY_BUFFER, vbo_object_1);
glVertexArrayPointer(...);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_object_1);
glDrawElements(...);
modelMatrix = glm::translate(modelMatrix, glm::vec3(5.0f, 0.0f, 0.0f));
glUniformMatrix4fv(uni_modelMatrix, 1, GL_FALSE, glm::value_ptr(modelMatrix));
glBindBuffer(GL_ARRAY_BUFFER, vbo_object_2);
glVertexArrayPointer(...);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_object_2);
glDrawElements(...);
}