An analysis of OpenGL glmultmatrixf () Glpushmatrix () Glpushmatrix ()

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.