0b460cfeaceb5ce090a93ee0d5ae34fd157c5edb
[dosdemo] / src / polyclip.h
1 #ifndef POLYCLIP_H_
2 #define POLYCLIP_H_
3
4 #include "3dgfx.h"
5
6 struct cplane {
7         float x, y, z;
8         float nx, ny, nz;
9 };
10
11 enum {
12         CLIP_LEFT, CLIP_RIGHT,
13         CLIP_BOTTOM, CLIP_TOP,
14         CLIP_NEAR, CLIP_FAR
15 };
16
17 /* Generic polygon clipper
18  * returns:
19  *  1 -> fully inside, not clipped
20  *  0 -> straddling the plane and clipped
21  * -1 -> fully outside, not clipped
22  * in all cases, vertices are copied to vout, and the vertex count is written
23  * to wherever voutnum is pointing
24  */
25 int clip_poly(struct g3d_vertex *vout, int *voutnum,
26                 const struct g3d_vertex *vin, int vnum, struct cplane *plane);
27
28 /* Special-case frustum clipper (might be slightly faster) */
29 int clip_frustum(struct g3d_vertex *vout, int *voutnum,
30                 const struct g3d_vertex *vin, int vnum, int fplane);
31
32 #endif  /* POLYCLIP_H_ */