zbuffer.c
930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* 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);
}
/*-----------------------------------------*/