- We need to generate our vertex buffer objects from vertices, indexes, normals, colors, uvs, etc.
In fact, you do not need to use VBO, on the client side Vertex Arrays also work. However, it is highly recommended that you use VBO because it makes life easier for the driver and ultimately also yours as the one who needs to manipulate the data. The code overhead is not taken into account (this is about the same as generating and loading texture data), and performance will only increase.
- then we can use GLM to transform the matrix, and we only use VBO to create or manipulate the grids, and finally we pass everything to the shaders of the GLSL vertices, like this ...
You are not limited to GLM. Any matrix math library will do. If you are looking for something you can use on C99, look at my (yet incomplete) linmath.h
https://github.com/datenwolf/linmath.h , which is just a header with static inline
. I have not tested yet whether duplication of code affects performance (the size of the code creates pressure in the L1 cache).
QUESTION: How do we do hierarchical transformations without pushMatrix / popMatrix? (or maybe we are doing a hierarchical transformation using our VBOs, is this possible?)
VBOs have nothing to do with this. What most users of the old-fashioned OpenGL problem give is those matrix stack functions that make OpenGL a bit like a scene graph. But this is not so.
If you forget about the matrix stack of the old OpenGL, it becomes obvious how to perform hierarchical transformations: on each hierarchy branch, create a copy of the transformation matrix and operate on it. You get a hierarchical tree of transformations, on each node the corresponding matrix is stored. Then you pass these matrices as uniforms to the vertex shader; or just one matrix if you are drawing a rigid object that has only one transformation. A few matrices that you usually need only for deformable objects, such as skeletal animation of such a character
worldtransform -> pelvis -> left upper leg -> left lower leg -> left foot right upper leg -> right lower leg -> right foot torso -> neck -> head -> left eye right eye facial deformation // this is a whole chapter of it own left upper arm -> left lower arm -> left hand right upper arm -> right lower arm -> right hand
Each time you call ->
in such a hierarchy, you make a copy of the matrix and continue to work on it. When you return to a higher level of the tree, you again begin to work with this matrix.
datenwolf
source share