读书人

opengl札记 glMultMatrixf() 区别

发布时间: 2013-09-10 13:42:18 作者: rapoo

opengl笔记—— glMultMatrixf() 区别 glLoadMatrixf()

能找到最好的解释来自:http://www.gamedev.net/topic/489879-glpushmatrixglpopmatrix--glloadmatrixf/

原理:

glPushMatrix didn't fail to push onto the stack; it's job is to push a copy of the current matrix onto a stack of matrices. Those matrices on the stack don't interact at all. You only manipulate the current, top-most, matrix at any given time.

Example 1:

   command                 resultglLoadMatrixf(A)       stack = [A]glPushMatrix()         stack = [A, A]glLoadMatrixf(B)       stack = [B, A]glPopMatrix()          stack = [A]

Example 2:
   command                 resultglLoadMatrixf(A)       stack = [A]glPushMatrix()         stack = [A, A]glMultMatrixf(B)       stack = [AB, A]glPopMatrix()          stack = [A]

注意:glTranslate* 等都是实际调用的是glMultMatrixf

实例:

看下面的代码:

770     glLoadMatrixf(matrixModelView.getTranspose());

不能是glMultMatrixf

读书人网 >编程

热点推荐