Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

glLoadIdentity and glPushMatrix/glPopMatrix, why not just use the former?

When applying transformations to objects we use glPushMatrix/glPopMatrix. But why don't we use glLoadIdentity only instead?

Thus

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

This is how its supposed to be done right?

can become

    glLoadIdentity()
    ..apply tranformations
    ...draw object
    glLoadIdentity()
    ..apply tranformations
    ...draw object
like image 968
quantum231 Avatar asked Jul 28 '12 01:07

quantum231


1 Answers

Because you wouldn't be able to do this:

glPushMatrix()
..apply tranformations
glPushMatrix()
..apply ADDITIONAL transformations
..draw object with combined transforms
glPopMatrix()
...draw object without the additional transforms.
glPopMatrix()
like image 53
Nicol Bolas Avatar answered Oct 02 '22 06:10

Nicol Bolas