## Remembering coordinates (Push/Pop Matrix ?)

Hello,
This is my first post so I would like to say Hello for everyone.
In school I'm programming in openlg and I have problem. That's my code:
Code :
```int DrawGLScene(GLvoid)
{	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

x=0.0f;

for (i = 0; i < 3; i++)
{

if (keys['1'])	a = 1;

if (keys['2'])	a = 2;

if (a == 1)
{

glTranslatef(0, 0.0f,-25.0f);
glRotatef(rtri,0.0f,1.0f,0.0f);
//	glPushMatrix();
glTranslatef(x, 0.0f,0.0f);

glBegin(GL_TRIANGLES);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f, 1.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f( 1.0f,-1.0f, 1.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f( 1.0f,-1.0f, 1.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f( 1.0f,-1.0f, -1.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f( 1.0f,-1.0f, -1.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(-1.0f,-1.0f, -1.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(-1.0f,-1.0f,-1.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f, 1.0f);
glEnd();

if (x == 0) x = -3;
else if (x < 0 ) x = 3;

rtri+=0.05f;

}
if (a == 2)
{

glTranslatef(x, 0.0f,-25.0f);
//	glPopMatrix();
glRotatef(rtri,0.0f,1.0f,0.0f);
glBegin(GL_TRIANGLES);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f, 1.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f( 1.0f,-1.0f, 1.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f( 1.0f,-1.0f, 1.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f( 1.0f,-1.0f, -1.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f( 1.0f,-1.0f, -1.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(-1.0f,-1.0f, -1.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(-1.0f,-1.0f,-1.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f, 1.0f);

glEnd();

if (x == 0) x = -3;
else if (x < 0 ) x = 3;

rtri+=0.05f;

}
}

return TRUE;
}```

Key '1' nad '2' are changing mode and my problem is how to do, to remember coordinates ? When I put key '2' everything is back to position 0, 0, 0 (efects the same like "translatef (0.0f, 0.0f, 0.0f)". I tried to use glPushMatrix and glPopMatrix but it doesn't work (probably I used these functions wrong). Can help me and correct this code ? Is very very importand for me...
Big Thanks.
ps. Sorry for my english... :/

Best Regards