我正在使用现代 OpenGL(2.1+ 版)。它与经典版本有更多不同。一切都是缓冲区,顶点缓冲区,元素缓冲区,统一缓冲区,......并且不推荐使用经典的做事方式:-|...
我的问题:在现代opengl中“移动”(无论如何,一般的转换)的最佳方式是什么?
目前,我这样做:
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(...);
}