zbuffer.c 930 Bytes
/* zbuffer.c */

#include "graphic.h"

static int *zbuffer;
static int *dzbuffer;
static int xsize, ysize;

/*-----------------------------------------*/
create_zbuffer( sx, sy)
int sx, sy;
{

	zbuffer = (int *)malloc( 4*sx*sy);
	dzbuffer = (int *)malloc( 4*sx*sy);
	xsize = sx;
	ysize = sy;
	clear_zbuffer();
}
/*-----------------------------------------*/
clear_zbuffer()
{
int x, y;
int *pf = zbuffer;
int *pfd = dzbuffer;
for (y=0; y<ysize; y++)
for (x=0; x<xsize; x++) {
	*pf++ = 0x7FFFFFFF;
	*pfd++ = 0x00010000;
	}
}
/*-----------------------------------------*/
put_zbuffer( x, y, dep, del)
int x, y;
int dep;
int del;
{
    *(zbuffer + y*xsize + x) = dep;
    *(dzbuffer + y*xsize + x) = del;
}	
/*-----------------------------------------*/
get_zbuffer( x, y, dep, del)
int x, y;
int *dep;
int *del;
{
	*dep = *(zbuffer + y*xsize + x);
	*del = *(dzbuffer + y*xsize + x);
}	
/*-----------------------------------------*/