Given:

<Z (Depth) Buffer Algorithm>=
  public void zbuffer() {
    for each polygon P in the list {
      for each pixel (x, y) that is contained in P {
        calculate zDepth of P at (x,y);
        if zDepth < zbuffer[x,y] {
          framebuffer[x,y] = color of P at (x, y);
          zbuffer[x,y] = zDepth;
        }
      }
    }
    display framebuffer;
  }