1 // $Header: x:/prj/tech/libsrc/r3d/RCS/primfunc.c 1.22 1997/10/03 13:03:23 KEVIN Exp $
13 // remove debugging macro
14 #undef r3_compute_prim_funcs
16 static int (*tmap_3d_funcs
[])(int, r3s_phandle
*, r3s_texture
) =
24 static int (*poly_3d_funcs
[])(int, r3s_phandle
*) =
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
);
59 void r3_tluc8_upoly(int c
, int n
, grs_vertex
**v
)
61 gr_tluc8_upoly(c
, n
, v
);
65 // determine which parameters to clip
66 static int clip_flags
[] =
78 R3_CLIP_RGB
| R3_CLIP_UV
,
82 R3_CLIP_RGB
| R3_CLIP_UV
,
86 // internal function to set up function pointers
88 void r3_compute_prim_funcs(int funcs
, char *name
)
90 void r3_compute_prim_funcs(int funcs
)
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;
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
) {
108 r3_3d_poly_func
= poly_3d_funcs
[poly_mode
];
113 Warning(("r3d: r3_compute_prim_funcs:\n TRISTRIP mode not supported in %s\n", name
));
117 Warning(("r3d: r3_compute_prim_funcs:\n TRIFAN mode not supported in %s\n", name
));
120 case R3_PL_QUADSTRIP
:
121 Warning(("r3d: r3_compute_prim_funcs:\n QUADSTRIP mode not supported in %s\n", name
));
125 Warning(("r3d: r3_compute_prim_funcs:\n Unhandled polygon drawing mode in %s\n", name
));
129 if (funcs
& R3FUNC_3D_TMAP
) {
130 switch (r3d_poly_flags
& R3_PL_MODE_MASK
) {
132 r3_3d_tmap_func
= tmap_3d_funcs
[poly_mode
];
137 Warning(("r3d: r3_compute_prim_funcs:\n TRISTRIP mode not supported in %s\n", name
));
141 Warning(("r3d: r3_compute_prim_funcs:\n TRIFAN mode not supported in %s\n", name
));
144 case R3_PL_QUADSTRIP
:
145 Warning(("r3d: r3_compute_prim_funcs:\n QUADSTRIP mode not supported in %s\n", name
));
148 Warning(("r3d: r3_compute_prim_funcs:\n Unhandled tmap drawing mode in %s\n", name
));
153 if (funcs
& R3FUNC_2D_POLY
) {
154 int index
= r3d_poly_flags
& (R3_PL_TEXTURE_MASK
+ R3_PL_LIGHT_MASK
);
159 r3_2d_poly_setup_func
= poly_setup_funcs
[index
>>1];
160 r3d_clip_flags
= clip_flags
[index
>>2];
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
;