When I set glTranslate to move backward or foward greater than 1.0f it doesn’t display anything. IF it is set at 1.0f it appears but isn’t changed at all. What is going on?

Heres my code:

/* OpenGL animation code goes here */
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);

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

        SwapBuffers (hDC);

You are drawing your object in camera position. So you can not see anything. However, as you are drawing a 2D object, you can solve this problem by using the function gluOrtho2D().

As Ehsan already stated: you are not applying a projection. You are loading the identity matrix and draw a 2D triangle (glVertex2), setting the z values to zero implicitly.

Moving “backward and forward” makes no sense then. (My assumption is, that you mean glTranslatef(0,0,x) and that you don’t do anything else to the matrix stacks.)

Without a projection applied, OpenGL maps z coordinates in the range [-1…1] to the depth buffer range [0…1]. See glDepthRange in the spec. Everything outside of the depth range gets clipped.

This explains, why the triangle disappears, when you shift it outside of the depth range using glTranslatef. And the shape doesn’t change because of the lack of a perspective projection.

Read Chapter 3 of the Red Book !