problem with glTranslatef

hi,

i’ve just started to progam with opengl and i’ve a little problem with glTranslatef().
glTranslatef(x,y,z);
when i use x and y it’s moving well on right and up but when i try to move with z the TRIANGLE that i’ve made disappears
anyone know why and can help me ?

sorry for my bad english i’m french.
i’m using dev-cpp.
Thanks a lot.

Looks like you’re moving your triangle behind your zFar-Plane, where it disappears.
Try setting your zFar-Plane further away via gluPerspective.

hum… it’s not working maybe i’ve done something wrong. this this a part of my code:

        glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        gluPerspective(0.0f,2.0f,0,40.0f);
        glTranslatef(0.0f, 0.0f, -0.01f);

        glPushMatrix ();
        glRotatef (theta, 0.0f, 0.0f, 1.0f);
        glBegin (GL_TRIANGLES);
        glColor3f (1.0f, 0.0f, 0.0f);   glVertex2f (0.0f, 1.0f);
        glColor3f (0.0f, 1.0f, 0.0f);   glVertex2f (0.87f, -0.5f);
        glColor3f (0.0f, 0.0f, 1.0f);   glVertex2f (-0.87f, -0.5f);
        glEnd ();
        glPopMatrix ();

        SwapBuffers (hDC);

        theta += 1.0f;
        Sleep (1);

anyone can help me ?
thanks a lot

You make a typical mistake : You don’t watch your matrices!
Things like gluPerspective have to be put into the (guess what) Projection-Matrix, whereas your drawing-calls go into the Modelview-Matrix.
Your code should look like this :

glMatrixMode(GL_PROJECTION);
glLoadIdentity;
gluPerspective(...);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
glBegin(...)

And another typical mistake; the near clip plane in gluPerspective must be positive.