After searching and reading about Modern OpenGL in order to upgrade my existing project, I'm a bit confused, since my 3D framework based on OpenGL 2.1.
so, as far as I learn...
We need to generate our Vertex-Buffer-Objects from vertices, indices, normals, colors, uvs, etc.
then we can use GLM for matrix transformation, and we only use VBO to create or manipulate meshes, finally we pass everything into GLSL vertex shader like this...
glm::mat4 MVP = projection * view * model; glUniformMatrix4fv(glGetUniformLocation(shaderProgramID, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP)); //or &MVP[0][0] // uniform mat4 MVP; // in vec3 Vertex; // void main(void) // { // gl_Position = MVP * vec4(Vertex, 1.0); //instead of ftransform(); // }
QUESTION: How we do hierarchical transformations without pushMatrix/popMatrix? (or maybe we do hierarchical transformation by using our VBOs, is it possible?)
If not possible, then how to achieve same result as pushMatrix/popMatrix by using GLM and C++ < stack > library?
Lets say I need something like this:
> Set identity
> Translate to X, Y, Z
> Draw Mesh 1
> Rotate 0.5 by X axis
> Draw Mesh 2
> Scale down to 0.1
> Draw Mesh 3
See Question&Answers more detail:os