hi every body
why i need pop and push in open gl
and when
best regards
Moon_Girl
hi every body
why i need pop and push in open gl
and when
best regards
Moon_Girl
Think of push/pop as matrix save/load, but works like a stack function.
Which means that the last item saved will be the first item to be be pulled back off the stack when a pop is called.
Example I have to objects, both I want to have a 45 degree rotation done on both, but want to do a 5 unit translation on one and a 10 unit translation on the other.
glRotatef(45, 1.0, 1.0, 1.0);
glPushMatrix();
glTranslatef( 5.0, 0.0, 0.0);
draw_object1();
glPopMatrix(); // I have restored the matrix back to before the translate was called.
glPushMatrix();
glTranslatef(10.0, 0.0,0.0);
draw_object2();
glPopMatrix();
Both objects get a 45 degree rotation, but each one has its own translate. Note you can also rotate and scale inside push/pop.
If you do not use push/pop matrix placing objects in your 3D world becomes very complicated. Since the next matrix rotations/translations would be ralative to the last ones.
With push/pop, you can more easly manage your objects.
glPushMatrix();
rotate/translate etc.
Draw_object
glPopMatrix();
draw next objects
For a good example check out my clock program: http://www.angelfire.com/linux/nexusone/index.html
Originally posted by MOON-GIRL:
[b]hi every body
why i need pop and push in open gl
and when
best regards
Moon_Girl[/b]
[This message has been edited by nexusone (edited 12-16-2002).]
thaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaank you very much
i understooood now
best regards
Moon_Girl
[This message has been edited by MOON-GIRL (edited 12-16-2002).]