[AD] Z-buffer

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


This is a (big) patch which adds the z-buffered rendering mode for 3D
polygons. The code comes from Calin Andrian's P3D library . I used it
with his kind permission.
I contribute to :
- upgrade Calin's code from Allegro 3.1 to the current version.
- write the C version of ASM functions (i.e copy & paste Mickael's
cscan* routines with some slight modifications).
- write an example 'exzbuf.c'.
I have also updated "Calin's entry" in the 'thanks._tx' file since he
made the major contributions. Docs have not been yet updated (I'll
release another patch to update docs).

Z-buffered mode is very easy to use (I have slightly modified Calin's
API to give it a "BITMAP-like" look). There are four steps :
- 1. create the z-buffer :
	create_zbuffer(BITMAP* bmp)
     bmp is the BITMAP you're planning to draw on. create_zbuffer uses
it to get the   dimensions of the buffer (or the screen). Only one
z-buffer can be defined (and used) at the same time. It's a 32 bit
z-buffer.

-2. clear the z-buffer (before drawing a new frame)
	clear_zbuffer(float z)
    writes 1/z into the z-buffer. 0 means far away.

-3. render the z-buffered polygons
    use the normal polygon3d, quad3d and triangle3d functions and OR'
the type with POLYTYPE_ZBUF.
    example : POLYTYPE_PTEX | POLYTYPE_ZBUF

-4. destroy the z-buffer
	destroy_zbuffer()
    surprisingly it destroys the z-buffer :-)

All this stuff has been tested under Linux and DJGPP. It seems it works.
Are there volunteers to test it under Windows (MSVC and Mingw32) ?
Enjoy it !

	Bertrand.

PS to Henrik : this patch cleans up the unused variables h_f, w and x of
poly3d.c

Attachment: zbuffer.diff.gz
Description: GNU Zip compressed data



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/