how to realize Z-buffer algorithm with C/C++ no on top of opengl?

please tell me how and where to get the source code for Z-buffer algrithm no based opengl!

A Z-buffer is not an algo, it is just a … buffer.
You want a “triangle rasterizer” with z interpolation.

Some links: