Glpushmatrix () and Glpopmatrix ()

Source: Internet
Author: User

Many of the online explanation of the above two functional principles of the article, but all are the more black, more and more confusing, in response to such problems, I think the project should be the first to abstract the problem into a simple mathematical model, and then in the mathematical perspective easier to understand.

OpenGL is a state machine, and each state variable is a Markov chain, which means that the latter change is based on the previous one.

This assumes that we are dealing with a three-dimensional model where the initial value of a state variable is m, where M is the matrix (which should be the unit matrix), if a series of state changes A1,a2,......,an.

That is, M multiplied by the n matrix--m*a1*a2*......*an, if we need to do a linear transformation of M, we need a linear transformation directly on M, assuming that the linear transformation is B, if the direct transformation, it becomes m*a1*a2*......*an*b, Seeing that this time B does not directly affect m body, this is because the matrix multiplication does not satisfy the commutative law. Only in very rare cases, matrix multiplication can be exchanged.

This time need to call the Glpushmatrix function, the previous transformation into the stack, m*a1*a2*......*an into M, and then do the transformation, then M*b, the last Call Glpopmatrix, the previous transformation out of the stack, then M*b*a1*a2*......*an, Achieve the results we want.

Glpushmatrix () and Glpopmatrix ()

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.