how to implement z-buffer algo

I know how to program in opengl, but still get stuck on how to go about in implementing algorithms. Please be assured that i know the basic concepts but dunno how to go about in implementation.
i hv to program in my assignment without using windows programming, in Opengl with C++ the following things::

  1. Implement the Scan-line Z-buffer algorithm. Code should identify and
    display the wire-frame of all visible surfaces of a given 3D object in any userspecified
    projection type and transformations.
  2. Implement the basic illumination model using a single point light source,
    and use Constant shading. Input values include all the required constants such
    as ambient intensity, light-source intensity and other coefficients, and choice of
    light source vector and view vector. Keep in mind that the view vector should be
    consistent with the view specified in the projection.
    Display the shaded visible surfaces of a given 3D object in any user-specified
    projection type and transformations.
  3. Extend the system to include multiple light sources, Goraud and Phong Shading

Any guidance will be helpful, im using visual studio 6 for programming in C++. :confused:

Here’s a quick run-down of a z-buffer algo - I’ll leave the details up to you or for further discussion:

  1. create a buffer of doubles with the same dimensions as your view area. initialize all entries to infinity.

  2. interpolate the z-value for each fragment in each polygon (should first be transformed into eye space); the z values of the fragments on the edge are trivial to compute (they are interpolated from the z-values of the vertices that define the edge). To find the z-value of the interior fragments interpolate using the interpolated values along opposite edges.

now multiply by the projection matrix to get screen space coordinates.

  1. for each fragment processed; if it’s z-value (determined from step 1) is less than the value stored in the z-buffer at x,y where x,y are obtained from the screen space calculation, update the z-buffer and draw the fragment.

that’s a really quick run thru off the top of my head…