Introduction to OpenGL - transform help

hi all,
just started doing opengl and i have a problem, i am doing the solar system project from the “Red Book” and i have come across a problem. I have added a planet and a moon but now i want to be able to add another planet which rotates around the sun, the code is below
glPushMatrix();
//sun and earth
sun();
glRotatef ((GLfloat) year, 0.0, 0.0, 1.0);
glTranslatef (2.0, 0.0, 0.0);
glRotatef ((GLfloat) day, 0.0, 0.0, 1.0);
earth();// draw earth
glTranslatef (0.5, 0.0, 0.0);
glRotatef ((GLfloat) day, 0.0, 0.0, 1.0);
moon();//draw moon
glTranslatef (0.5, 0.0, 0.0);
glRotatef ((GLfloat) year, 0.0, 0.0, 1.0);
mars(); //draw mars
glPopMatrix();

i cannot get it to go back to the origin, the sun, can anyone give a help please
cheers

Well, since you draw the sun directly after pushing the matrix to the stack, I assume you are placed at the origin when you enter the code you posted, which means you push this position to the stack. Later, when you pop the matrix, you are placed back to the position you pushed.

So, if you draw something directly after glPopMatrix, it should appear at the same place as the sun.