as the title, i want to why and when to clear the matrix to identity matrix with glIndentity().
plz tell me about the principle of it or your experience.
Programming,make a whole new world.
Like 1 in the real numbers, anything multiplied by the identity matrix is unchanged. That is, for any matrix M, MI = M (where I is the identity matrix).
Looking at that, you would set any transformations to identity that you don''t want to affect the final vertex produced. For example, if you''re specifying your vertices in window coordinates, you''d set your view and projection matrices to identity so that they don''t change the values.
if the matrix hasn''t been transform to identity matrix,then the new matrix will be based on the matrixs operation previously.we can use the identity matrix to clear all matrixs previously and make a new matrix stack,is it right?
You set the current matrix to the identity matrix, so that you can always have things in the same place, frame-to-frame. If you never cleared the identity matrix, things would be really wierd. And using glLoadIdentity() doesn''t clear the STACK, only the current matrix, to the identity matrix.
That''s true, if you''re using glRotatef() or glTranslatef(), etc, then you use glIdentity() to reset everything each frame. If you''re using glLoadMatrix() then you don''t need to, since glLoadMatrix() replaces the current matrix with the one you supply.