Z-BUFFER algorithm


This is the a ZBUFFER demonstration.

It's planned to demonstrate the Zbuffer algorithm like a debugger. In the future You may use it to go through the algorithm step-by-step, setting breakpoint or just running the whole.

The applet does a lot of message switching, so it could be slow a little on an i486 like machine - but if You would like to see how does it work, You can follow with Your eyes when the algorithm do or do not puts a pixel on the screen.

We draw two triangles. As You'll see, first we draw the upper half of a triangle then the lower half - just like You saw at the Breaking down the triangle section before. The discussed algorithm was modified at the computing of dXsy, dXey and dZsy: now we compute them not (...)/(Y2-Y1) but (...)/abs(Y2-Y1) to make it fit to both of the upper and the lower half triangle.



The program has the following clases:

demoview - is the supervisoring class and the applet

Z80Screen - the display object which registrates the pixels' color

Zbuffdemo - it realizes the algorithm step-by-step. The demoview class calls it for a single step - one line in the algorithm.

Szin and NewPix - These are two structures for RGB colors and for the communication between demoview and Zbuffdemo.

(This java applet has been written by Csordás ákos)