2012-07-28 4 views
3

Lors de l'application de transformations aux objets, nous utilisons glPushMatrix/glPopMatrix. Mais pourquoi n'utilisons-nous glLoadIdentity qu'à la place?glLoadIdentity et glPushMatrix/glPopMatrix, pourquoi ne pas simplement utiliser le premier?

Ainsi

glPushMatrix() 
    ..apply tranformations 
    ...draw object 
    glPopMatrix() 
    glPushMatrix() 
    ..apply tranformations 
    ...draw object 
    glPopMatrix() 

Voici comment son supposé faire droit?

peut devenir

glLoadIdentity() 
    ..apply tranformations 
    ...draw object 
    glLoadIdentity() 
    ..apply tranformations 
    ...draw object 

Répondre

6

Parce que vous ne seriez pas en mesure de le faire:

glPushMatrix() 
..apply tranformations 
glPushMatrix() 
..apply ADDITIONAL transformations 
..draw object with combined transforms 
glPopMatrix() 
...draw object without the additional transforms. 
glPopMatrix() 
Questions connexes