backporting...
[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 /* only checks if the polygon would be clipped by the plane, and classifies it
29  * as inside/outside/straddling, without actually producing a clipped polygon.
30  * return values are the same as clip_poly.
31  */
32 int check_clip_poly(const struct g3d_vertex *v, int vnum, struct cplane *plane);
33
34 /* Special-case frustum clipper (might be slightly faster) */
35 int clip_frustum(struct g3d_vertex *vout, int *voutnum,
36                 const struct g3d_vertex *vin, int vnum, int fplane);
37
38 #endif  /* POLYCLIP_H_ */