convert line ends
[canaan.git] / prj / tech / libsrc / r3d / primfunc.c
blob112fa0777b75c8b53e803343dddc4bb918b6baa2
1 // $Header: x:/prj/tech/libsrc/r3d/RCS/primfunc.c 1.22 1997/10/03 13:03:23 KEVIN Exp $
3 #include <dbg.h>
5 #include <ctxts.h>
6 #include <clipcon_.h>
7 #include <prim.h>
8 #include <primcon_.h>
9 #include <primfunc.h>
10 #include <primpoly.h>
11 #include <primtab_.h>
13 // remove debugging macro
14 #undef r3_compute_prim_funcs
16 static int (*tmap_3d_funcs[])(int, r3s_phandle *, r3s_texture) =
18 r3_any,
19 r3_clip_any,
20 r3_check_any,
21 r3_check_clip_any,
24 static int (*poly_3d_funcs[])(int, r3s_phandle *) =
26 r3_implicit_any,
27 r3_clip_implicit_any,
28 r3_check_implicit_any,
29 r3_check_clip_implicit_any,
32 static int (*prim_line_func)(r3s_phandle p0, r3s_phandle p1);
33 static int (*prim_point_func)(r3s_phandle p);
34 static poly_setup_func *poly_setup_funcs;
35 static int (*convert_func)(int n, r3s_phandle *vl);
37 // use this to setup alternative drivers (like d3d, for example)
38 void r3_setup_prim_funcs(
39 poly_setup_func *setup_func_list,
40 int (*convert)(int n, r3s_phandle *vl),
41 int (*line_func)(r3s_phandle p0, r3s_phandle p1),
42 int (*point_func)(r3s_phandle p))
44 poly_setup_funcs = setup_func_list;
45 convert_func = convert;
46 prim_line_func = line_func;
47 prim_point_func = point_func;
50 #if 0 // i think these are pretty obsolete
51 typedef int (*tmap_func)(grs_bitmap *, int n, grs_vertex **);
53 int r3_tluc8_poly(int c, int n, grs_vertex **v)
55 gr_tluc8_poly(c, n, v);
56 return 0;
59 void r3_tluc8_upoly(int c, int n, grs_vertex **v)
61 gr_tluc8_upoly(c, n, v);
63 #endif
65 // determine which parameters to clip
66 static int clip_flags[] =
69 R3_CLIP_I,
70 R3_CLIP_RGB,
71 R3_CLIP_I,
73 R3_CLIP_I,
74 R3_CLIP_RGB,
75 R3_CLIP_I,
76 R3_CLIP_UV,
77 R3_CLIP_ALL,
78 R3_CLIP_RGB | R3_CLIP_UV,
79 R3_CLIP_ALL,
80 R3_CLIP_UV,
81 R3_CLIP_ALL,
82 R3_CLIP_RGB | R3_CLIP_UV,
83 R3_CLIP_ALL
86 // internal function to set up function pointers
87 #ifdef DBG_ON
88 void r3_compute_prim_funcs(int funcs, char *name)
89 #else
90 void r3_compute_prim_funcs(int funcs)
91 #endif
93 int poly_mode;
95 r3_convert_func = convert_func;
97 // compute poly index if we do any 3d poly functions
98 if (funcs & (R3FUNC_3D_POLY | R3FUNC_3D_TMAP)) {
99 if (r3d_poly_flags & R3_PL_CHECK_FACING)
100 poly_mode = r3d_clip_mode != R3_NO_CLIP ? 3 : 2;
101 else
102 poly_mode = r3d_clip_mode != R3_NO_CLIP ? 1 : 0;
105 if (funcs & R3FUNC_3D_POLY) {
106 switch (r3d_poly_flags & R3_PL_MODE_MASK) {
107 case R3_PL_POLYGON:
108 r3_3d_poly_func = poly_3d_funcs[poly_mode];
109 break;
111 #ifdef DBG_ON
112 case R3_PL_TRISTRIP:
113 Warning(("r3d: r3_compute_prim_funcs:\n TRISTRIP mode not supported in %s\n", name));
114 break;
116 case R3_PL_TRIFAN:
117 Warning(("r3d: r3_compute_prim_funcs:\n TRIFAN mode not supported in %s\n", name));
118 break;
120 case R3_PL_QUADSTRIP:
121 Warning(("r3d: r3_compute_prim_funcs:\n QUADSTRIP mode not supported in %s\n", name));
122 break;
124 default:
125 Warning(("r3d: r3_compute_prim_funcs:\n Unhandled polygon drawing mode in %s\n", name));
126 #endif
129 if (funcs & R3FUNC_3D_TMAP) {
130 switch (r3d_poly_flags & R3_PL_MODE_MASK) {
131 case R3_PL_POLYGON:
132 r3_3d_tmap_func = tmap_3d_funcs[poly_mode];
133 break;
135 #ifdef DBG_ON
136 case R3_PL_TRISTRIP:
137 Warning(("r3d: r3_compute_prim_funcs:\n TRISTRIP mode not supported in %s\n", name));
138 break;
140 case R3_PL_TRIFAN:
141 Warning(("r3d: r3_compute_prim_funcs:\n TRIFAN mode not supported in %s\n", name));
142 break;
144 case R3_PL_QUADSTRIP:
145 Warning(("r3d: r3_compute_prim_funcs:\n QUADSTRIP mode not supported in %s\n", name));
146 break;
147 default:
148 Warning(("r3d: r3_compute_prim_funcs:\n Unhandled tmap drawing mode in %s\n", name));
149 #endif
153 if (funcs & R3FUNC_2D_POLY) {
154 int index = r3d_poly_flags & (R3_PL_TEXTURE_MASK + R3_PL_LIGHT_MASK);
156 if (r3d_clip_2d)
157 index+=2;
159 r3_2d_poly_setup_func = poly_setup_funcs[index>>1];
160 r3d_clip_flags = clip_flags[index>>2];
161 r3d_do_setup = TRUE;
163 if (funcs & R3FUNC_2D_LINE) {
164 r3_2d_line_func = prim_line_func;
166 if (funcs & R3FUNC_2D_POINT) {
167 r3_2d_point_func = prim_point_func;