Hi
I am totally new to opengl.
I am in a question of how to reset the position after applying it a time.
ex - I am using following code to draw a cube.

glTranslatef(0, 1, 0);
glColor4f(0.3, 0.3, 0.3, 0.3 );
glutSolidCube(2);
After doing above how to rest the position to draw a new cube?
Actually by calling

glTranslatef(0, -1, 0);
I could do that.
Instead any inbuild method for resetting?
I mean resetting colors, position ,etc...

ZbuffeR

03-23-2011, 01:53 AM

Use glPushMatrix before the first translation, then glPopMatrix after drawing the first cube, to go back to the transformation saved by push matrix. This works for transformation matrices only (ie. rotation, translation, scaling, shear, etc).

_arts_

03-23-2011, 01:53 AM

glPushMatrix();
// do transformations
// draw
glPopMatrix();
// we're in state before all done transformations.