Mail Archives: djgpp/1997/03/30/22:34:27
In article <E7rD4t DOT 9zL AT news DOT uwindsor DOT ca>,
Doug Johnson <johnsoe AT cs DOT uwindsor DOT ca> wrote:
> I've been playing with the 3-D example in Allegro, the one with the tiled
>floor-grid. I have replaced the grid-drawing function with a box-drawing
>function, but I notice that the box's sides are not drawn as expected. Does
>this mean that my function must calculate the proper order to render the
>polygons? Is there any simple way to do this?
The polygons are drawn on the screen in the order they are passed to the
polygon drawing routine (a bit obvious, that one). There are several ways
of correcting the screen order of polygons. Allegro's EX22 (the one with
spinning cubes) uses a depth-sort algorithm that sorts the faces so that
the face with the greatest average z co-ordinate for it's vertices gets
drawn first. See EX22.C and also look at the documentation of the qsort
function in libc.inf. However, this doesn't always work when polygons
are close to each other, and it never works if polygons intercept.
Alternative approaches are to use the Painter's algorithm or Z buffering.
AE.
--
Andrei Ellman - URL: http://www.xs4all.nl/~ellman/ae-a - ae1 AT york DOT ac DOT uk
"All I wanna do is have some fun :-) || ae-a AT minster DOT york DOT ac DOT uk
I've got the feeling I'm not the only one" || mailto:ellman AT xs4all DOT nl
-- Sheryl Crow :-) || It's what you make of it.
- Raw text -