glOrtho() in fixed function pipeline - Unable to see change in z-axis void display(void) {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
    glBegin(GL_LINES);
    glVertex3d(0.75, 0.25, 0.0);
    glVertex3d(0.75, 0.25, -0.75);
    glEnd();
    glFlush();
}

void init(void) {
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}


I should be able to see line from (0.75, 0.25, 0.0)  to (0.75, 0.25, -0.75), but I can't see anything on the screen.

However, I'm able to see the line using snippet below

glVertex3d(0.35, 0.25, 0.0);
glVertex3d(0.75, 0.25, -0.75);


Can anyone explain this behavior?
This projection is a 2d projection, with the Z axis pointing into your screen. When both vertices with the same X&amp;Y are projected to screen space they will occupy the same screen coordinate so your line will either be 1 pixel or invisible.

If you are expecting a difference in screen position from those 2 coordinates then you need a perspective projection.