Use correct conversions when translating array colors.
[mesa.git] / src / mesa / math / m_translate.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 5.1
4 *
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /*
26 * New (3.1) transformation code written by Keith Whitwell.
27 */
28
29
30 #include "glheader.h"
31 #include "mtypes.h" /* GLchan hack */
32 #include "colormac.h"
33
34 #include "m_translate.h"
35
36
37
38 typedef void (*trans_1f_func)(GLfloat *to,
39 CONST void *ptr,
40 GLuint stride,
41 GLuint start,
42 GLuint n );
43
44 typedef void (*trans_1ui_func)(GLuint *to,
45 CONST void *ptr,
46 GLuint stride,
47 GLuint start,
48 GLuint n );
49
50 typedef void (*trans_1ub_func)(GLubyte *to,
51 CONST void *ptr,
52 GLuint stride,
53 GLuint start,
54 GLuint n );
55
56 typedef void (*trans_4ub_func)(GLubyte (*to)[4],
57 CONST void *ptr,
58 GLuint stride,
59 GLuint start,
60 GLuint n );
61
62 typedef void (*trans_4us_func)(GLushort (*to)[4],
63 CONST void *ptr,
64 GLuint stride,
65 GLuint start,
66 GLuint n );
67
68 typedef void (*trans_4f_func)(GLfloat (*to)[4],
69 CONST void *ptr,
70 GLuint stride,
71 GLuint start,
72 GLuint n );
73
74 typedef void (*trans_3f_func)(GLfloat (*to)[3],
75 CONST void *ptr,
76 GLuint stride,
77 GLuint start,
78 GLuint n );
79
80
81
82
83 #define TYPE_IDX(t) ((t) & 0xf)
84 #define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
85
86
87 /* This macro is used on other systems, so undefine it for this module */
88
89 #undef CHECK
90
91 static trans_1f_func _math_trans_1f_tab[MAX_TYPES];
92 static trans_1ui_func _math_trans_1ui_tab[MAX_TYPES];
93 static trans_1ub_func _math_trans_1ub_tab[MAX_TYPES];
94 static trans_3f_func _math_trans_3f_tab[MAX_TYPES];
95 static trans_4ub_func _math_trans_4ub_tab[5][MAX_TYPES];
96 static trans_4us_func _math_trans_4us_tab[5][MAX_TYPES];
97 static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES];
98 static trans_4f_func _math_trans_4fc_tab[5][MAX_TYPES];
99
100
101 #define PTR_ELT(ptr, elt) (((SRC *)ptr)[elt])
102
103
104 #define TAB(x) _math_trans##x##_tab
105 #define ARGS GLuint start, GLuint n
106 #define SRC_START start
107 #define DST_START 0
108 #define STRIDE stride
109 #define NEXT_F f += stride
110 #define NEXT_F2
111 #define CHECK
112
113
114
115
116 /* GL_BYTE
117 */
118 #define SRC GLbyte
119 #define SRC_IDX TYPE_IDX(GL_BYTE)
120 #define TRX_3F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
121 #define TRX_4F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
122 #define TRX_4FC(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
123 #define TRX_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) )
124 #define TRX_US(ch, f,n) ch = BYTE_TO_USHORT( PTR_ELT(f,n) )
125 #define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
126
127
128 #define SZ 4
129 #define INIT init_trans_4_GLbyte_raw
130 #define DEST_4F trans_4_GLbyte_4f_raw
131 #define DEST_4FC trans_4_GLbyte_4fc_raw
132 #define DEST_4UB trans_4_GLbyte_4ub_raw
133 #define DEST_4US trans_4_GLbyte_4us_raw
134 #include "m_trans_tmp.h"
135
136 #define SZ 3
137 #define INIT init_trans_3_GLbyte_raw
138 #define DEST_4F trans_3_GLbyte_4f_raw
139 #define DEST_4FC trans_3_GLbyte_4fc_raw
140 #define DEST_4UB trans_3_GLbyte_4ub_raw
141 #define DEST_4US trans_3_GLbyte_4us_raw
142 #define DEST_3F trans_3_GLbyte_3f_raw
143 #include "m_trans_tmp.h"
144
145 #define SZ 2
146 #define INIT init_trans_2_GLbyte_raw
147 #define DEST_4F trans_2_GLbyte_4f_raw
148 #define DEST_4FC trans_2_GLbyte_4fc_raw
149 #include "m_trans_tmp.h"
150
151 #define SZ 1
152 #define INIT init_trans_1_GLbyte_raw
153 #define DEST_4F trans_1_GLbyte_4f_raw
154 #define DEST_4FC trans_1_GLbyte_4fc_raw
155 #define DEST_1UB trans_1_GLbyte_1ub_raw
156 #define DEST_1UI trans_1_GLbyte_1ui_raw
157 #include "m_trans_tmp.h"
158
159 #undef SRC
160 #undef TRX_3F
161 #undef TRX_4F
162 #undef TRX_4FC
163 #undef TRX_UB
164 #undef TRX_US
165 #undef TRX_UI
166 #undef SRC_IDX
167
168
169 /* GL_UNSIGNED_BYTE
170 */
171 #define SRC GLubyte
172 #define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE)
173 #define TRX_3F(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n))
174 #define TRX_4F(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n))
175 #define TRX_4FC(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n))
176 #define TRX_UB(ub, f,n) ub = PTR_ELT(f,n)
177 #define TRX_US(us, f,n) us = UBYTE_TO_USHORT(PTR_ELT(f,n))
178 #define TRX_UI(f,n) (GLuint)PTR_ELT(f,n)
179
180 /* 4ub->4ub handled in special case below.
181 */
182 #define SZ 4
183 #define INIT init_trans_4_GLubyte_raw
184 #define DEST_4F trans_4_GLubyte_4f_raw
185 #define DEST_4FC trans_4_GLubyte_4fc_raw
186 #define DEST_4US trans_4_GLubyte_4us_raw
187 #include "m_trans_tmp.h"
188
189
190 #define SZ 3
191 #define INIT init_trans_3_GLubyte_raw
192 #define DEST_4UB trans_3_GLubyte_4ub_raw
193 #define DEST_4US trans_3_GLubyte_4us_raw
194 #define DEST_3F trans_3_GLubyte_3f_raw
195 #define DEST_4F trans_3_GLubyte_4f_raw
196 #define DEST_4FC trans_3_GLubyte_4fc_raw
197 #include "m_trans_tmp.h"
198
199
200 #define SZ 1
201 #define INIT init_trans_1_GLubyte_raw
202 #define DEST_1UI trans_1_GLubyte_1ui_raw
203 #define DEST_1UB trans_1_GLubyte_1ub_raw
204 #include "m_trans_tmp.h"
205
206 #undef SRC
207 #undef SRC_IDX
208 #undef TRX_3F
209 #undef TRX_4F
210 #undef TRX_4FC
211 #undef TRX_UB
212 #undef TRX_US
213 #undef TRX_UI
214
215
216 /* GL_SHORT
217 */
218 #define SRC GLshort
219 #define SRC_IDX TYPE_IDX(GL_SHORT)
220 #define TRX_3F(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) )
221 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
222 #define TRX_4FC(f,n) (GLfloat)( PTR_ELT(f,n) )
223 #define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n))
224 #define TRX_US(us, f,n) us = SHORT_TO_USHORT(PTR_ELT(f,n))
225 #define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
226
227
228 #define SZ 4
229 #define INIT init_trans_4_GLshort_raw
230 #define DEST_4F trans_4_GLshort_4f_raw
231 #define DEST_4FC trans_4_GLshort_4fc_raw
232 #define DEST_4UB trans_4_GLshort_4ub_raw
233 #define DEST_4US trans_4_GLshort_4us_raw
234 #include "m_trans_tmp.h"
235
236 #define SZ 3
237 #define INIT init_trans_3_GLshort_raw
238 #define DEST_4F trans_3_GLshort_4f_raw
239 #define DEST_4FC trans_3_GLshort_4fc_raw
240 #define DEST_4UB trans_3_GLshort_4ub_raw
241 #define DEST_4US trans_3_GLshort_4us_raw
242 #define DEST_3F trans_3_GLshort_3f_raw
243 #include "m_trans_tmp.h"
244
245 #define SZ 2
246 #define INIT init_trans_2_GLshort_raw
247 #define DEST_4F trans_2_GLshort_4f_raw
248 #define DEST_4FC trans_2_GLshort_4fc_raw
249 #include "m_trans_tmp.h"
250
251 #define SZ 1
252 #define INIT init_trans_1_GLshort_raw
253 #define DEST_4F trans_1_GLshort_4f_raw
254 #define DEST_4FC trans_1_GLshort_4fc_raw
255 #define DEST_1UB trans_1_GLshort_1ub_raw
256 #define DEST_1UI trans_1_GLshort_1ui_raw
257 #include "m_trans_tmp.h"
258
259
260 #undef SRC
261 #undef SRC_IDX
262 #undef TRX_3F
263 #undef TRX_4F
264 #undef TRX_4FC
265 #undef TRX_UB
266 #undef TRX_US
267 #undef TRX_UI
268
269
270 /* GL_UNSIGNED_SHORT
271 */
272 #define SRC GLushort
273 #define SRC_IDX TYPE_IDX(GL_UNSIGNED_SHORT)
274 #define TRX_3F(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) )
275 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
276 #define TRX_4FC(f,n) (GLfloat)( PTR_ELT(f,n) )
277 #define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8)
278 #define TRX_US(us,f,n) us = (GLushort) (PTR_ELT(f,n) >> 8)
279 #define TRX_UI(f,n) (GLuint) PTR_ELT(f,n)
280
281
282 #define SZ 4
283 #define INIT init_trans_4_GLushort_raw
284 #define DEST_4F trans_4_GLushort_4f_raw
285 #define DEST_4FC trans_4_GLushort_4fc_raw
286 #define DEST_4UB trans_4_GLushort_4ub_raw
287 #define DEST_4US trans_4_GLushort_4us_raw
288 #include "m_trans_tmp.h"
289
290 #define SZ 3
291 #define INIT init_trans_3_GLushort_raw
292 #define DEST_4F trans_3_GLushort_4f_raw
293 #define DEST_4FC trans_3_GLushort_4fc_raw
294 #define DEST_4UB trans_3_GLushort_4ub_raw
295 #define DEST_4US trans_3_GLushort_4us_raw
296 #define DEST_3F trans_3_GLushort_3f_raw
297 #include "m_trans_tmp.h"
298
299 #define SZ 2
300 #define INIT init_trans_2_GLushort_raw
301 #define DEST_4F trans_2_GLushort_4f_raw
302 #define DEST_4FC trans_2_GLushort_4fc_raw
303 #include "m_trans_tmp.h"
304
305 #define SZ 1
306 #define INIT init_trans_1_GLushort_raw
307 #define DEST_4F trans_1_GLushort_4f_raw
308 #define DEST_4FC trans_1_GLushort_4fc_raw
309 #define DEST_1UB trans_1_GLushort_1ub_raw
310 #define DEST_1UI trans_1_GLushort_1ui_raw
311 #include "m_trans_tmp.h"
312
313 #undef SRC
314 #undef SRC_IDX
315 #undef TRX_3F
316 #undef TRX_4F
317 #undef TRX_4FC
318 #undef TRX_UB
319 #undef TRX_US
320 #undef TRX_UI
321
322
323 /* GL_INT
324 */
325 #define SRC GLint
326 #define SRC_IDX TYPE_IDX(GL_INT)
327 #define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
328 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
329 #define TRX_4FC(f,n) (GLfloat)( PTR_ELT(f,n) )
330 #define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n))
331 #define TRX_US(us, f,n) us = INT_TO_USHORT(PTR_ELT(f,n))
332 #define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
333
334
335 #define SZ 4
336 #define INIT init_trans_4_GLint_raw
337 #define DEST_4F trans_4_GLint_4f_raw
338 #define DEST_4FC trans_4_GLint_4fc_raw
339 #define DEST_4UB trans_4_GLint_4ub_raw
340 #define DEST_4US trans_4_GLint_4us_raw
341 #include "m_trans_tmp.h"
342
343 #define SZ 3
344 #define INIT init_trans_3_GLint_raw
345 #define DEST_4F trans_3_GLint_4f_raw
346 #define DEST_4FC trans_3_GLint_4fc_raw
347 #define DEST_4UB trans_3_GLint_4ub_raw
348 #define DEST_4US trans_3_GLint_4us_raw
349 #define DEST_3F trans_3_GLint_3f_raw
350 #include "m_trans_tmp.h"
351
352 #define SZ 2
353 #define INIT init_trans_2_GLint_raw
354 #define DEST_4F trans_2_GLint_4f_raw
355 #define DEST_4FC trans_2_GLint_4fc_raw
356 #include "m_trans_tmp.h"
357
358 #define SZ 1
359 #define INIT init_trans_1_GLint_raw
360 #define DEST_4F trans_1_GLint_4f_raw
361 #define DEST_4FC trans_1_GLint_4fc_raw
362 #define DEST_1UB trans_1_GLint_1ub_raw
363 #define DEST_1UI trans_1_GLint_1ui_raw
364 #include "m_trans_tmp.h"
365
366
367 #undef SRC
368 #undef SRC_IDX
369 #undef TRX_3F
370 #undef TRX_4F
371 #undef TRX_4FC
372 #undef TRX_UB
373 #undef TRX_US
374 #undef TRX_UI
375
376
377 /* GL_UNSIGNED_INT
378 */
379 #define SRC GLuint
380 #define SRC_IDX TYPE_IDX(GL_UNSIGNED_INT)
381 #define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
382 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
383 #define TRX_4FC(f,n) (GLfloat)( PTR_ELT(f,n) )
384 #define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24)
385 #define TRX_US(us, f,n) us = (GLshort) (PTR_ELT(f,n) >> 16)
386 #define TRX_UI(f,n) PTR_ELT(f,n)
387
388
389 #define SZ 4
390 #define INIT init_trans_4_GLuint_raw
391 #define DEST_4F trans_4_GLuint_4f_raw
392 #define DEST_4FC trans_4_GLuint_4fc_raw
393 #define DEST_4UB trans_4_GLuint_4ub_raw
394 #define DEST_4US trans_4_GLuint_4us_raw
395 #include "m_trans_tmp.h"
396
397 #define SZ 3
398 #define INIT init_trans_3_GLuint_raw
399 #define DEST_4F trans_3_GLuint_4f_raw
400 #define DEST_4FC trans_3_GLuint_4fc_raw
401 #define DEST_4UB trans_3_GLuint_4ub_raw
402 #define DEST_4US trans_3_GLuint_4us_raw
403 #define DEST_3F trans_3_GLuint_3f_raw
404 #include "m_trans_tmp.h"
405
406 #define SZ 2
407 #define INIT init_trans_2_GLuint_raw
408 #define DEST_4F trans_2_GLuint_4f_raw
409 #define DEST_4FC trans_2_GLuint_4fc_raw
410 #include "m_trans_tmp.h"
411
412 #define SZ 1
413 #define INIT init_trans_1_GLuint_raw
414 #define DEST_4F trans_1_GLuint_4f_raw
415 #define DEST_4FC trans_1_GLuint_4fc_raw
416 #define DEST_1UB trans_1_GLuint_1ub_raw
417 #define DEST_1UI trans_1_GLuint_1ui_raw
418 #include "m_trans_tmp.h"
419
420 #undef SRC
421 #undef SRC_IDX
422 #undef TRX_3F
423 #undef TRX_4F
424 #undef TRX_4FC
425 #undef TRX_UB
426 #undef TRX_US
427 #undef TRX_UI
428
429
430 /* GL_DOUBLE
431 */
432 #define SRC GLdouble
433 #define SRC_IDX TYPE_IDX(GL_DOUBLE)
434 #define TRX_3F(f,n) (GLfloat) PTR_ELT(f,n)
435 #define TRX_4F(f,n) (GLfloat) PTR_ELT(f,n)
436 #define TRX_4FC(f,n) (GLfloat) PTR_ELT(f,n)
437 #define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_UBYTE(ub, PTR_ELT(f,n))
438 #define TRX_US(us,f,n) UNCLAMPED_FLOAT_TO_USHORT(us, PTR_ELT(f,n))
439 #define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n)
440 #define TRX_1F(f,n) (GLfloat) PTR_ELT(f,n)
441
442
443 #define SZ 4
444 #define INIT init_trans_4_GLdouble_raw
445 #define DEST_4F trans_4_GLdouble_4f_raw
446 #define DEST_4FC trans_4_GLdouble_4fc_raw
447 #define DEST_4UB trans_4_GLdouble_4ub_raw
448 #define DEST_4US trans_4_GLdouble_4us_raw
449 #include "m_trans_tmp.h"
450
451 #define SZ 3
452 #define INIT init_trans_3_GLdouble_raw
453 #define DEST_4F trans_3_GLdouble_4f_raw
454 #define DEST_4FC trans_3_GLdouble_4fc_raw
455 #define DEST_4UB trans_3_GLdouble_4ub_raw
456 #define DEST_4US trans_3_GLdouble_4us_raw
457 #define DEST_3F trans_3_GLdouble_3f_raw
458 #include "m_trans_tmp.h"
459
460 #define SZ 2
461 #define INIT init_trans_2_GLdouble_raw
462 #define DEST_4F trans_2_GLdouble_4f_raw
463 #define DEST_4FC trans_2_GLdouble_4fc_raw
464 #include "m_trans_tmp.h"
465
466 #define SZ 1
467 #define INIT init_trans_1_GLdouble_raw
468 #define DEST_4F trans_1_GLdouble_4f_raw
469 #define DEST_4FC trans_1_GLdouble_4fc_raw
470 #define DEST_1UB trans_1_GLdouble_1ub_raw
471 #define DEST_1UI trans_1_GLdouble_1ui_raw
472 #define DEST_1F trans_1_GLdouble_1f_raw
473 #include "m_trans_tmp.h"
474
475 #undef SRC
476 #undef SRC_IDX
477
478 /* GL_FLOAT
479 */
480 #define SRC GLfloat
481 #define SRC_IDX TYPE_IDX(GL_FLOAT)
482 #define SZ 4
483 #define INIT init_trans_4_GLfloat_raw
484 #define DEST_4UB trans_4_GLfloat_4ub_raw
485 #define DEST_4US trans_4_GLfloat_4us_raw
486 #define DEST_4F trans_4_GLfloat_4f_raw
487 #define DEST_4FC trans_4_GLfloat_4fc_raw
488 #include "m_trans_tmp.h"
489
490 #define SZ 3
491 #define INIT init_trans_3_GLfloat_raw
492 #define DEST_4F trans_3_GLfloat_4f_raw
493 #define DEST_4FC trans_3_GLfloat_4fc_raw
494 #define DEST_4UB trans_3_GLfloat_4ub_raw
495 #define DEST_4US trans_3_GLfloat_4us_raw
496 #define DEST_3F trans_3_GLfloat_3f_raw
497 #include "m_trans_tmp.h"
498
499 #define SZ 2
500 #define INIT init_trans_2_GLfloat_raw
501 #define DEST_4F trans_2_GLfloat_4f_raw
502 #define DEST_4FC trans_2_GLfloat_4fc_raw
503 #include "m_trans_tmp.h"
504
505 #define SZ 1
506 #define INIT init_trans_1_GLfloat_raw
507 #define DEST_4F trans_1_GLfloat_4f_raw
508 #define DEST_4FC trans_1_GLfloat_4fc_raw
509 #define DEST_1UB trans_1_GLfloat_1ub_raw
510 #define DEST_1UI trans_1_GLfloat_1ui_raw
511 #define DEST_1F trans_1_GLfloat_1f_raw
512
513 #include "m_trans_tmp.h"
514
515 #undef SRC
516 #undef SRC_IDX
517 #undef TRX_3F
518 #undef TRX_4F
519 #undef TRX_4FC
520 #undef TRX_UB
521 #undef TRX_US
522 #undef TRX_UI
523
524
525 static void trans_4_GLubyte_4ub_raw(GLubyte (*t)[4],
526 CONST void *Ptr,
527 GLuint stride,
528 ARGS )
529 {
530 const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride;
531 GLuint i;
532
533 if (((((long) f | (long) stride)) & 3L) == 0L) {
534 /* Aligned.
535 */
536 for (i = DST_START ; i < n ; i++, f += stride) {
537 COPY_4UBV( t[i], f );
538 }
539 } else {
540 for (i = DST_START ; i < n ; i++, f += stride) {
541 t[i][0] = f[0];
542 t[i][1] = f[1];
543 t[i][2] = f[2];
544 t[i][3] = f[3];
545 }
546 }
547 }
548
549
550 static void init_translate_raw(void)
551 {
552 MEMSET( TAB(_1ui), 0, sizeof(TAB(_1ui)) );
553 MEMSET( TAB(_1ub), 0, sizeof(TAB(_1ub)) );
554 MEMSET( TAB(_3f), 0, sizeof(TAB(_3f)) );
555 MEMSET( TAB(_4ub), 0, sizeof(TAB(_4ub)) );
556 MEMSET( TAB(_4us), 0, sizeof(TAB(_4us)) );
557 MEMSET( TAB(_4f), 0, sizeof(TAB(_4f)) );
558 MEMSET( TAB(_4fc), 0, sizeof(TAB(_4fc)) );
559
560 init_trans_4_GLbyte_raw();
561 init_trans_3_GLbyte_raw();
562 init_trans_2_GLbyte_raw();
563 init_trans_1_GLbyte_raw();
564 init_trans_1_GLubyte_raw();
565 init_trans_3_GLubyte_raw();
566 init_trans_4_GLubyte_raw();
567 init_trans_4_GLshort_raw();
568 init_trans_3_GLshort_raw();
569 init_trans_2_GLshort_raw();
570 init_trans_1_GLshort_raw();
571 init_trans_4_GLushort_raw();
572 init_trans_3_GLushort_raw();
573 init_trans_2_GLushort_raw();
574 init_trans_1_GLushort_raw();
575 init_trans_4_GLint_raw();
576 init_trans_3_GLint_raw();
577 init_trans_2_GLint_raw();
578 init_trans_1_GLint_raw();
579 init_trans_4_GLuint_raw();
580 init_trans_3_GLuint_raw();
581 init_trans_2_GLuint_raw();
582 init_trans_1_GLuint_raw();
583 init_trans_4_GLdouble_raw();
584 init_trans_3_GLdouble_raw();
585 init_trans_2_GLdouble_raw();
586 init_trans_1_GLdouble_raw();
587 init_trans_4_GLfloat_raw();
588 init_trans_3_GLfloat_raw();
589 init_trans_2_GLfloat_raw();
590 init_trans_1_GLfloat_raw();
591
592 TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub_raw;
593 }
594
595
596 #undef TAB
597 #ifdef CLASS
598 #undef CLASS
599 #endif
600 #undef ARGS
601 #undef CHECK
602 #undef SRC_START
603 #undef DST_START
604 #undef NEXT_F
605 #undef NEXT_F2
606
607
608
609
610
611 void _math_init_translate( void )
612 {
613 init_translate_raw();
614 }
615
616
617
618 void _math_trans_1f(GLfloat *to,
619 CONST void *ptr,
620 GLuint stride,
621 GLenum type,
622 GLuint start,
623 GLuint n )
624 {
625 _math_trans_1f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
626 }
627
628 void _math_trans_1ui(GLuint *to,
629 CONST void *ptr,
630 GLuint stride,
631 GLenum type,
632 GLuint start,
633 GLuint n )
634 {
635 _math_trans_1ui_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
636 }
637
638 void _math_trans_1ub(GLubyte *to,
639 CONST void *ptr,
640 GLuint stride,
641 GLenum type,
642 GLuint start,
643 GLuint n )
644 {
645 _math_trans_1ub_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
646 }
647
648
649 void _math_trans_4ub(GLubyte (*to)[4],
650 CONST void *ptr,
651 GLuint stride,
652 GLenum type,
653 GLuint size,
654 GLuint start,
655 GLuint n )
656 {
657 _math_trans_4ub_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
658 }
659
660 void _math_trans_4chan( GLchan (*to)[4],
661 CONST void *ptr,
662 GLuint stride,
663 GLenum type,
664 GLuint size,
665 GLuint start,
666 GLuint n )
667 {
668 #if CHAN_TYPE == GL_UNSIGNED_BYTE
669 _math_trans_4ub( to, ptr, stride, type, size, start, n );
670 #elif CHAN_TYPE == GL_UNSIGNED_SHORT
671 _math_trans_4us( to, ptr, stride, type, size, start, n );
672 #elif CHAN_TYPE == GL_FLOAT
673 _math_trans_4fc( to, ptr, stride, type, size, start, n );
674 #endif
675 }
676
677 void _math_trans_4us(GLushort (*to)[4],
678 CONST void *ptr,
679 GLuint stride,
680 GLenum type,
681 GLuint size,
682 GLuint start,
683 GLuint n )
684 {
685 _math_trans_4us_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
686 }
687
688 void _math_trans_4f(GLfloat (*to)[4],
689 CONST void *ptr,
690 GLuint stride,
691 GLenum type,
692 GLuint size,
693 GLuint start,
694 GLuint n )
695 {
696 _math_trans_4f_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
697 }
698
699 void _math_trans_4fc(GLfloat (*to)[4],
700 CONST void *ptr,
701 GLuint stride,
702 GLenum type,
703 GLuint size,
704 GLuint start,
705 GLuint n )
706 {
707 _math_trans_4fc_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
708 }
709
710 void _math_trans_3f(GLfloat (*to)[3],
711 CONST void *ptr,
712 GLuint stride,
713 GLenum type,
714 GLuint start,
715 GLuint n )
716 {
717 _math_trans_3f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
718 }