2012-07-28 22 views
3

將變換應用於對象時,我們使用glPushMatrix/glPopMatrix。但是,爲什麼我們不僅僅使用glLoadIdentity呢?glLoadIdentity和glPushMatrix/glPopMatrix,爲什麼不使用前者?

因此

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

這是它應該怎麼做吧?

可以成爲

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

回答

6

因爲你不能就能夠做到這一點:

glPushMatrix() 
..apply tranformations 
glPushMatrix() 
..apply ADDITIONAL transformations 
..draw object with combined transforms 
glPopMatrix() 
...draw object without the additional transforms. 
glPopMatrix() 
相關問題