Basic z coordinate usage displays blank view

Ok, I am a little confused on how to use z coordinates. The following code does not display a yellow triangle. When I remove the glOrtho call and change the z coordinates of the vertices back to 0.0 from 2.0 it displays. I would have expected changing all three z coordinates to affect the size of the triangle (similar to a scale). What am I missing here?


    glClearColor(.0f, .0f, .0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable (GL_DEPTH_TEST);
    glColor3f(1.0f, 0.85f, 0.35f);
    glOrtho(-1, 1, -1, 1, 1, 100);
    glBegin(GL_POLYGON);
    {
        glVertex3f(  0.0,  0.6, 2.0);
        glVertex3f( -0.2, -0.3, 2.0);
        glVertex3f(  0.0, -0.3 ,2.0);
    }
    glEnd();

You must not mix matrix modes. In other words, don’t call glOrtho when MODELVIEW matrix is active.

Thanks Aleksander,
I changed the code to the following but it made no difference:

    
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable (GL_DEPTH_TEST);

    glColor3f(1.0f, 0.85f, 0.35f);
    
    glMatrixMode(GL_PROJECTION);    
    glOrtho(-1, 1, -1, 1, 1, 100);
    glMatrixMode(GL_MODELVIEW);

    glBegin(GL_POLYGON);
    {
        glVertex3f(  0.0,  0.6, 2.0);
        glVertex3f( -0.2, -0.3, 2.0);
        glVertex3f(  0.0, -0.3, 2.0);
    }
    glEnd();

glViewport() is probably missing, as well as SwapBuffers(), or equivalent.
(After adding those two commands, I get valid output from your code.)

Let me verify something more basic. Given these two sets of vectors:

{-0.2f, 0.5f, -10.0f},
            {0.3f, -0.5f, -10.0f},
            {0.8f, 0.5f, -10.0f}

{-0.2f, 0.5f, -2.0f},
            {0.3f, -0.5f, -2.0f},
            {0.8f, 0.5f, -2.0f}

Should these triangles appear as the same size in the view? OR asked another way, changing the Z coordinate should in fact change the apparent size of the triangle, correct?

[QUOTE=devonM;1245352]
Should these triangles appear as the same size in the view? OR asked another way, changing the Z coordinate should in fact change the apparent size of the triangle, correct?[/QUOTE]

Okay. The simple mistake in my understanding was that when using orthographic projection altering the Z coordinate does not change the size of the object whereas perspective projection does. :doh: