From: ellman AT xs4all DOT nl () Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro 3D : Sorting Polygons Date: 30 Mar 1997 21:45:33 GMT Organization: XS4ALL Message-ID: <5hmmtt$5bg$1@news0.xs4all.nl> References: NNTP-Posting-Host: xs1.xs4all.nl Lines: 27 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article , Doug Johnson 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.