As I mentioned in my previous blog, the coordinates in OpenGL are represented by the line vectors, which correspond to the transpose of the transformation matrix used in the matrix transformation and the way in which the back multiplication is used. This article uses the following code to interpret the function directly and its following diagram
void glmultmatrixf (const glfloat *m)
void Glpushmatrix (void)
void Glpushmatrix (void)
The meaning. The code in the function rotate (float angle, float x, float y, float z) is to let the coordinate point around the vector (x, y, z) rotate the angle angle, the direction of rotation conforms to the right-hand helix rule. The functions rotate (0, 1, 0), rotate (three, 0, 0, 1), rotate (45, 1, 0, 0) correspond to the transpose of A,b,c respectively.
1 Glmatrixmode (gl_modelview);2 matrixview.identity ();3Matrixview.rotate ( $,0,1,0);4Matrixview.translate (0,0, -cameradistance);5 6 Glpushmatrix ();7GLMULTMATRIXF (MatrixView.Get());8 9 matrixview.identity ();TenMatrixview.rotate ( $,0,0,1); One A Glpushmatrix (); -GLMULTMATRIXF (MatrixView.Get()); - the matrixview.identity (); -Matrixview.rotate ( $,1,0,0); - - Glpushmatrix (); +GLMULTMATRIXF (MatrixView.Get()); - + Glpopmatrix (); A Glpopmatrix (); atGlpopmatrix ();
The operation of the stack top matrix is as follows:
The initial default of the stack-top matrix is a unit matrix, after which the matrix that is loaded with the current matrix is first multiplied by the coordinates, using the function glmultmatrixf. The following seven images are the teapot positions corresponding to the top states of the seven stacks, the red, green, and blue arrows representing the x, y, z axes, respectively.
(1)
(2)
(3)
(4)
(5)
(6)
(7)
OpenGL glmultmatrixf () Glpushmatrix () Glpushmatrix () analysis