/*
	** save the depth buffer to the CPU and turn off the color buffer
      *  This could be done by using FBOs instead.
	*/
	glReadPixels(0, 0, winWidth, winHeight, GL_DEPTH_COMPONENT, 
	             GL_FLOAT, depthSave);
      glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

	/*
	** make the line 2 pixels thick
	** this gets rid of the Z-buffer errors at the silhouette edges
	glLineWidth(2.f);
	*/

      /*
	** clear the stencil buffer for this object
	*/
        glEnable(GL_STENCIL_TEST);
	glStencilFunc(GL_ALWAYS, 0, 0); /* clear stencil for this object */
	glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);

	/*
	** set the polygon offset a tiny bit
	*/
	glEnable(GL_POLYGON_OFFSET_FILL);
	glPolygonOffset(0.5, 1.0);

	drawMyObject();
	/*	DrawCylinder(cv, cn, FACETS, RIBS);*/
	/*	DrawObjects(); /* your routine */

	glDisable(GL_POLYGON_OFFSET_FILL);

        /*
	** set up for stenciling, write a '1' whereever there is 
	** a  line
	*/
	glStencilFunc(GL_ALWAYS, 1, 1);
	glStencilOp(GL_ZERO, GL_ZERO, GL_REPLACE);

        /*
	** disable writes to the Z-buffer test
	** test for less than or equal to
	*/
	glDepthFunc(GL_LEQUAL); 
	glDepthMask(GL_FALSE);

	/*
	**  render all polygons in outline mode without updating the 
	**   color buffer or the depth buffer, 
	**   this sets the stencil bit where for all the non-hidden
	**   lines in the object
	*/
	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

	drawMyObject();
	/*	DrawCylinder(cv, cn, FACETS, RIBS);*/
	/*	DrawObjects(); /* your routine */

	/* 
	** now the stencil only has the bit set for the non-hidden lines
	** Turn on the color buffer
	** restore the depth buffer
	** write only were the stencil bit is set
	** now the depth buffer and color buffer are current
	**/

	glDepthMask(GL_TRUE);
	glDepthFunc(GL_ALWAYS); 
	glDisable(GL_STENCIL_TEST);

    	glPushMatrix();
    	glLoadIdentity();
    	glMatrixMode(GL_PROJECTION);
    	glPushMatrix();
    	glLoadIdentity();
    	glOrtho(0, 1, 0, 1, 0, 1);

	//glRasterPos2f(0, 0);
	//glDrawPixels(winWidth, winHeight, GL_DEPTH_COMPONENT, GL_FLOAT, depthSave);
	// these are deprecated functions.  You would use a texture of type GL_FLOAT and draw a 
 	// full screen quad (-1,-1, -1, 1, 1, -1,) at the appropriate Z and then in a fragment
  	// program, you would use the sampler to replace the Z value of the fragment using nearest neighbor lookup
 	//

	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();

	glEnable(GL_STENCIL_TEST);

	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
	glStencilFunc(GL_EQUAL, 1, 1);
	glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
	glColor3f(1,1,1);
	drawMyObject();

	/*
	**  reset state
	**  
	*/
	glDisable(GL_STENCIL_TEST);
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	glDepthFunc(GL_LESS);
	glLineWidth(1.f);