Why is there a glMatrixMode in OpenGL?

后端 未结 4 543
攒了一身酷
攒了一身酷 2021-02-05 13:10

I just don\'t understand what OpenGL\'s glMatrixMode is for.

As far as I can see, when glMatrixMode(GL_MODELVIEW) is called, it is followed by

4条回答
  •  甜味超标
    2021-02-05 13:28

    All geometry coordinates undergo several linear transformations in sequence. While any linear transformation can be expressed by a single matrix, often you want to think of a sequence of transformations and edit the sequence, and if you have only a single matrix you could only change the ends of that sequence. By providing several transformation steps, OpenGL gives you several places in the middle where you can change the transformation as well.

    Calling glMatrixMode before emitting geometry has no effect at all. You call glMatrixMode before editing the transform matrix, to determine where in the overall sequence those edits appear.

    (NB: Looking at the sequence makes a lot more sense if you remember that translation and rotation are not commutative, because translation changes the center of rotation. Similarly translation and scaling are not commutative.)

提交回复
热议问题