void ZBuffer( void) {
int x,y;
for (x=0; x<w;
x++) {
for (y=0;y<h;
y++) {
WritePixel(x,y,
bck_color);
WriteZ(x,y,0);
}
}
for (each primitive)
{
for (each pixel in
the projected primitive) {
double pz = z
coordinate of the (x,y) pixel;
if (pz <= ReadZ(x,y)) {
WritePixel(x,y, color);
WriteZ(x,y,pz);
}
}
}
} /* Zbuffer */