1 // $Header: x:/prj/tech/libsrc/g2/RCS/grtm.c 1.1 1997/05/16 09:48:55 KEVIN Exp $
9 static void vpl_to_ppl(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
, g2s_point
**ppl
)
12 float inv_u_scale
, inv_v_scale
;
13 float inv_ltab_size
= 1.0/grd_light_table_size
;
14 grs_point
*pl
= (grs_point
*)(ppl
+ n
);
17 inv_u_scale
= 1.0/bm
->w
;
18 inv_v_scale
= 1.0/bm
->h
;
22 ppl
[i
] = (g2s_point
*)(&pl
[i
]);
26 pl
[i
].i
= fix_float(vpl
[i
]->i
) * inv_ltab_size
;
28 pl
[i
].u
= fix_float(vpl
[i
]->u
) * inv_u_scale
;
29 pl
[i
].v
= fix_float(vpl
[i
]->v
) * inv_v_scale
;
30 pl
[i
].w
= fix_float(vpl
[i
]->w
);
35 typedef int (map_func
)(int n
, g2s_point
**ppl
);
36 static int do_map(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
, map_func
*f
)
41 ppl
= (g2s_point
**)gr_alloc_temp(n
* (4 + sizeof(grs_point
)));
42 vpl_to_ppl (bm
, n
, vpl
, ppl
);
48 int gr_poly(int c
, int n
, grs_vertex
**vpl
)
52 return do_map(NULL
, n
, vpl
, g2_map
);
55 int gr_spoly(int c
, int n
, grs_vertex
**vpl
)
58 g2_spoly_setup (NULL
);
59 return do_map(NULL
, n
, vpl
, g2_map
);
62 int gr_lin_map(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
)
64 g2_lin_map_setup (bm
);
65 return do_map(bm
, n
, vpl
, g2_map
);
68 int gr_lit_lin_map(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
)
70 g2_lit_lin_map_setup (bm
);
71 return do_map(bm
, n
, vpl
, g2_map
);
74 int gr_clut_lin_map(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
, uchar
*clut
)
78 if (gr_get_fill_type()==FILL_NORM
) {
79 gr_set_fill_type(FILL_CLUT
);
80 gr_set_fill_parm(clut
);
81 code
= gr_lin_map(bm
, n
, vpl
);
82 gr_set_fill_type(FILL_NORM
);
84 code
= gr_lin_map(bm
, n
, vpl
);
89 int gr_per_map(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
)
92 return do_map(bm
, n
, vpl
, g2_per_map
);
95 int gr_lit_per_map(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
)
97 g2_lit_per_map_setup(bm
);
98 return do_map(bm
, n
, vpl
, g2_per_map
);
101 int gr_clut_per_map(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
, uchar
*clut
)
104 if (gr_get_fill_type()==FILL_NORM
) {
105 gr_set_fill_type(FILL_CLUT
);
106 gr_set_fill_parm(clut
);
107 code
= gr_per_map(bm
, n
, vpl
);
108 gr_set_fill_type(FILL_NORM
);
110 code
= gr_per_map(bm
, n
, vpl
);
115 void gr_upoly(int c
, int n
, grs_vertex
**vpl
)
118 g2_upoly_setup (NULL
);
119 do_map(NULL
, n
, vpl
, g2_umap
);
122 void gr_uspoly(int c
, int n
, grs_vertex
**vpl
)
125 g2_uspoly_setup (NULL
);
126 do_map(NULL
, n
, vpl
, g2_umap
);
129 void gr_lin_umap(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
)
131 g2_lin_umap_setup (bm
);
132 do_map(bm
, n
, vpl
, g2_umap
);
135 void gr_lit_lin_umap(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
)
137 g2_lit_lin_umap_setup (bm
);
138 do_map(bm
, n
, vpl
, g2_umap
);
141 void gr_clut_lin_umap(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
, uchar
*clut
)
143 if (gr_get_fill_type()==FILL_NORM
) {
144 gr_set_fill_type(FILL_CLUT
);
145 gr_set_fill_parm(clut
);
146 gr_lin_umap(bm
, n
, vpl
);
147 gr_set_fill_type(FILL_NORM
);
149 gr_lin_umap(bm
, n
, vpl
);
153 void gr_per_umap(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
)
155 g2_per_umap_setup (bm
);
156 do_map(bm
, n
, vpl
, g2_per_umap
);
159 void gr_lit_per_umap(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
)
161 g2_lit_per_umap_setup (bm
);
162 do_map(bm
, n
, vpl
, g2_per_umap
);
165 void gr_clut_per_umap(grs_bitmap
*bm
, int n
, grs_vertex
**vpl
, uchar
*clut
)
167 if (gr_get_fill_type()==FILL_NORM
) {
168 gr_set_fill_type(FILL_CLUT
);
169 gr_set_fill_parm(clut
);
170 gr_per_map(bm
, n
, vpl
);
171 gr_set_fill_type(FILL_NORM
);
173 gr_per_map(bm
, n
, vpl
);