deepstone
diff src/mglimpl.h @ 28:11d14f688485
added clipping
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 22 Sep 2013 06:38:08 +0300 |
parents | 5ff8ce78059a |
children | 1fa939507d8b |
line diff
1.1 --- a/src/mglimpl.h Sun Sep 22 02:47:46 2013 +0300 1.2 +++ b/src/mglimpl.h Sun Sep 22 06:38:08 2013 +0300 1.3 @@ -5,6 +5,7 @@ 1.4 1.5 #define MATRIX_STACK_SIZE 8 1.6 #define MAX_LIGHTS 4 1.7 +#define MAX_CLIP_PLANES 6 1.8 1.9 #define ZTILE_SIZE 16384 1.10 #define ZTILE_SHIFT 14 1.11 @@ -34,6 +35,11 @@ 1.12 int cidx; 1.13 }; 1.14 1.15 +struct plane { 1.16 + vec3_t pt; 1.17 + vec3_t normal; 1.18 +}; 1.19 + 1.20 struct texture { 1.21 int width, height; 1.22 int xshift, yshift; 1.23 @@ -47,12 +53,15 @@ 1.24 int mmode, mtop[2]; 1.25 mat4_t matrix[2][MATRIX_STACK_SIZE]; 1.26 int prim; 1.27 - struct vertex curv, v[4]; 1.28 + struct vertex curv, v[6]; 1.29 int vidx; 1.30 int vp[4]; /* viewport */ 1.31 int col_range; /* color interpolation range */ 1.32 vec4_t lpos[MAX_LIGHTS]; 1.33 float lint[MAX_LIGHTS]; 1.34 + float ambient; 1.35 + 1.36 + struct plane clip_planes[MAX_CLIP_PLANES + 1]; 1.37 1.38 struct texture tex; 1.39 }; 1.40 @@ -64,6 +73,7 @@ 1.41 int num_ztiles; 1.42 }; 1.43 1.44 +#define IS_ENABLED(f, x) ((f) & (1 << (x))) 1.45 1.46 #define vertex_to_fixedvertex(v, vx) \ 1.47 do { \ 1.48 @@ -91,4 +101,7 @@ 1.49 void mgl_draw_line(struct vertex *v0, struct vertex *v1); 1.50 void mgl_draw_poly(struct vertex *v, int numv); 1.51 1.52 +int mgl_clip_init(struct state *state); 1.53 +int mgl_clip_poly(struct vertex *v, int vnum); 1.54 + 1.55 #endif /* MGL_IMPL_H_ */