[FMIFS]
[reactos.git] / reactos / dll / opengl / mesa / math / m_translate.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.1
4 *
5 * Copyright (C) 1999-2006 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 * \brief Translate vectors of numbers between various types.
27 * \author Keith Whitwell.
28 */
29
30
31 #include <precomp.h>
32
33 #include "main/mtypes.h" /* GLchan hack */
34
35 typedef void (*trans_1f_func)(GLfloat *to,
36 CONST void *ptr,
37 GLuint stride,
38 GLuint start,
39 GLuint n );
40
41 typedef void (*trans_1ui_func)(GLuint *to,
42 CONST void *ptr,
43 GLuint stride,
44 GLuint start,
45 GLuint n );
46
47 typedef void (*trans_1ub_func)(GLubyte *to,
48 CONST void *ptr,
49 GLuint stride,
50 GLuint start,
51 GLuint n );
52
53 typedef void (*trans_4ub_func)(GLubyte (*to)[4],
54 CONST void *ptr,
55 GLuint stride,
56 GLuint start,
57 GLuint n );
58
59 typedef void (*trans_4us_func)(GLushort (*to)[4],
60 CONST void *ptr,
61 GLuint stride,
62 GLuint start,
63 GLuint n );
64
65 typedef void (*trans_4f_func)(GLfloat (*to)[4],
66 CONST void *ptr,
67 GLuint stride,
68 GLuint start,
69 GLuint n );
70
71 typedef void (*trans_3fn_func)(GLfloat (*to)[3],
72 CONST void *ptr,
73 GLuint stride,
74 GLuint start,
75 GLuint n );
76
77
78
79
80 #define TYPE_IDX(t) ((t) & 0xf)
81 #define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
82
83
84 /* This macro is used on other systems, so undefine it for this module */
85
86 #undef CHECK
87
88 static trans_1f_func _math_trans_1f_tab[MAX_TYPES];
89 static trans_1ui_func _math_trans_1ui_tab[MAX_TYPES];
90 static trans_1ub_func _math_trans_1ub_tab[MAX_TYPES];
91 static trans_3fn_func _math_trans_3fn_tab[MAX_TYPES];
92 static trans_4ub_func _math_trans_4ub_tab[5][MAX_TYPES];
93 static trans_4us_func _math_trans_4us_tab[5][MAX_TYPES];
94 static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES];
95 static trans_4f_func _math_trans_4fn_tab[5][MAX_TYPES];
96
97
98 #define PTR_ELT(ptr, elt) (((SRC *)ptr)[elt])
99
100
101 #define TAB(x) _math_trans##x##_tab
102 #define ARGS GLuint start, GLuint n
103 #define SRC_START start
104 #define DST_START 0
105 #define STRIDE stride
106 #define NEXT_F f += stride
107 #define NEXT_F2
108 #define CHECK
109
110
111
112
113 /**
114 * Translate from GL_BYTE.
115 */
116 #define SRC GLbyte
117 #define SRC_IDX TYPE_IDX(GL_BYTE)
118 #define TRX_3FN(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
119 #if 1
120 #define TRX_4F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
121 #else
122 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
123 #endif
124 #define TRX_4FN(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
125 #define TRX_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) )
126 #define TRX_US(ch, f,n) ch = BYTE_TO_USHORT( PTR_ELT(f,n) )
127 #define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
128
129
130 #define SZ 4
131 #define INIT init_trans_4_GLbyte_raw
132 #define DEST_4F trans_4_GLbyte_4f_raw
133 #define DEST_4FN trans_4_GLbyte_4fn_raw
134 #define DEST_4UB trans_4_GLbyte_4ub_raw
135 #define DEST_4US trans_4_GLbyte_4us_raw
136 #include "m_trans_tmp.h"
137
138 #define SZ 3
139 #define INIT init_trans_3_GLbyte_raw
140 #define DEST_4F trans_3_GLbyte_4f_raw
141 #define DEST_4FN trans_3_GLbyte_4fn_raw
142 #define DEST_4UB trans_3_GLbyte_4ub_raw
143 #define DEST_4US trans_3_GLbyte_4us_raw
144 #define DEST_3FN trans_3_GLbyte_3fn_raw
145 #include "m_trans_tmp.h"
146
147 #define SZ 2
148 #define INIT init_trans_2_GLbyte_raw
149 #define DEST_4F trans_2_GLbyte_4f_raw
150 #define DEST_4FN trans_2_GLbyte_4fn_raw
151 #include "m_trans_tmp.h"
152
153 #define SZ 1
154 #define INIT init_trans_1_GLbyte_raw
155 #define DEST_4F trans_1_GLbyte_4f_raw
156 #define DEST_4FN trans_1_GLbyte_4fn_raw
157 #define DEST_1UB trans_1_GLbyte_1ub_raw
158 #define DEST_1UI trans_1_GLbyte_1ui_raw
159 #include "m_trans_tmp.h"
160
161 #undef SRC
162 #undef TRX_3FN
163 #undef TRX_4F
164 #undef TRX_4FN
165 #undef TRX_UB
166 #undef TRX_US
167 #undef TRX_UI
168 #undef SRC_IDX
169
170
171 /**
172 * Translate from GL_UNSIGNED_BYTE.
173 */
174 #define SRC GLubyte
175 #define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE)
176 #define TRX_3FN(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n))
177 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
178 #define TRX_4FN(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n))
179 #define TRX_UB(ub, f,n) ub = PTR_ELT(f,n)
180 #define TRX_US(us, f,n) us = UBYTE_TO_USHORT(PTR_ELT(f,n))
181 #define TRX_UI(f,n) (GLuint)PTR_ELT(f,n)
182
183 /* 4ub->4ub handled in special case below.
184 */
185 #define SZ 4
186 #define INIT init_trans_4_GLubyte_raw
187 #define DEST_4F trans_4_GLubyte_4f_raw
188 #define DEST_4FN trans_4_GLubyte_4fn_raw
189 #define DEST_4US trans_4_GLubyte_4us_raw
190 #include "m_trans_tmp.h"
191
192
193 #define SZ 3
194 #define INIT init_trans_3_GLubyte_raw
195 #define DEST_4UB trans_3_GLubyte_4ub_raw
196 #define DEST_4US trans_3_GLubyte_4us_raw
197 #define DEST_3FN trans_3_GLubyte_3fn_raw
198 #define DEST_4F trans_3_GLubyte_4f_raw
199 #define DEST_4FN trans_3_GLubyte_4fn_raw
200 #include "m_trans_tmp.h"
201
202
203 #define SZ 1
204 #define INIT init_trans_1_GLubyte_raw
205 #define DEST_1UI trans_1_GLubyte_1ui_raw
206 #define DEST_1UB trans_1_GLubyte_1ub_raw
207 #include "m_trans_tmp.h"
208
209 #undef SRC
210 #undef SRC_IDX
211 #undef TRX_3FN
212 #undef TRX_4F
213 #undef TRX_4FN
214 #undef TRX_UB
215 #undef TRX_US
216 #undef TRX_UI
217
218
219 /* GL_SHORT
220 */
221 #define SRC GLshort
222 #define SRC_IDX TYPE_IDX(GL_SHORT)
223 #define TRX_3FN(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) )
224 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
225 #define TRX_4FN(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) )
226 #define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n))
227 #define TRX_US(us, f,n) us = SHORT_TO_USHORT(PTR_ELT(f,n))
228 #define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
229
230
231 #define SZ 4
232 #define INIT init_trans_4_GLshort_raw
233 #define DEST_4F trans_4_GLshort_4f_raw
234 #define DEST_4FN trans_4_GLshort_4fn_raw
235 #define DEST_4UB trans_4_GLshort_4ub_raw
236 #define DEST_4US trans_4_GLshort_4us_raw
237 #include "m_trans_tmp.h"
238
239 #define SZ 3
240 #define INIT init_trans_3_GLshort_raw
241 #define DEST_4F trans_3_GLshort_4f_raw
242 #define DEST_4FN trans_3_GLshort_4fn_raw
243 #define DEST_4UB trans_3_GLshort_4ub_raw
244 #define DEST_4US trans_3_GLshort_4us_raw
245 #define DEST_3FN trans_3_GLshort_3fn_raw
246 #include "m_trans_tmp.h"
247
248 #define SZ 2
249 #define INIT init_trans_2_GLshort_raw
250 #define DEST_4F trans_2_GLshort_4f_raw
251 #define DEST_4FN trans_2_GLshort_4fn_raw
252 #include "m_trans_tmp.h"
253
254 #define SZ 1
255 #define INIT init_trans_1_GLshort_raw
256 #define DEST_4F trans_1_GLshort_4f_raw
257 #define DEST_4FN trans_1_GLshort_4fn_raw
258 #define DEST_1UB trans_1_GLshort_1ub_raw
259 #define DEST_1UI trans_1_GLshort_1ui_raw
260 #include "m_trans_tmp.h"
261
262
263 #undef SRC
264 #undef SRC_IDX
265 #undef TRX_3FN
266 #undef TRX_4F
267 #undef TRX_4FN
268 #undef TRX_UB
269 #undef TRX_US
270 #undef TRX_UI
271
272
273 /* GL_UNSIGNED_SHORT
274 */
275 #define SRC GLushort
276 #define SRC_IDX TYPE_IDX(GL_UNSIGNED_SHORT)
277 #define TRX_3FN(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) )
278 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
279 #define TRX_4FN(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) )
280 #define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8)
281 #define TRX_US(us,f,n) us = PTR_ELT(f,n)
282 #define TRX_UI(f,n) (GLuint) PTR_ELT(f,n)
283
284
285 #define SZ 4
286 #define INIT init_trans_4_GLushort_raw
287 #define DEST_4F trans_4_GLushort_4f_raw
288 #define DEST_4FN trans_4_GLushort_4fn_raw
289 #define DEST_4UB trans_4_GLushort_4ub_raw
290 #define DEST_4US trans_4_GLushort_4us_raw
291 #include "m_trans_tmp.h"
292
293 #define SZ 3
294 #define INIT init_trans_3_GLushort_raw
295 #define DEST_4F trans_3_GLushort_4f_raw
296 #define DEST_4FN trans_3_GLushort_4fn_raw
297 #define DEST_4UB trans_3_GLushort_4ub_raw
298 #define DEST_4US trans_3_GLushort_4us_raw
299 #define DEST_3FN trans_3_GLushort_3fn_raw
300 #include "m_trans_tmp.h"
301
302 #define SZ 2
303 #define INIT init_trans_2_GLushort_raw
304 #define DEST_4F trans_2_GLushort_4f_raw
305 #define DEST_4FN trans_2_GLushort_4fn_raw
306 #include "m_trans_tmp.h"
307
308 #define SZ 1
309 #define INIT init_trans_1_GLushort_raw
310 #define DEST_4F trans_1_GLushort_4f_raw
311 #define DEST_4FN trans_1_GLushort_4fn_raw
312 #define DEST_1UB trans_1_GLushort_1ub_raw
313 #define DEST_1UI trans_1_GLushort_1ui_raw
314 #include "m_trans_tmp.h"
315
316 #undef SRC
317 #undef SRC_IDX
318 #undef TRX_3FN
319 #undef TRX_4F
320 #undef TRX_4FN
321 #undef TRX_UB
322 #undef TRX_US
323 #undef TRX_UI
324
325
326 /* GL_INT
327 */
328 #define SRC GLint
329 #define SRC_IDX TYPE_IDX(GL_INT)
330 #define TRX_3FN(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
331 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
332 #define TRX_4FN(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
333 #define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n))
334 #define TRX_US(us, f,n) us = INT_TO_USHORT(PTR_ELT(f,n))
335 #define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
336
337
338 #define SZ 4
339 #define INIT init_trans_4_GLint_raw
340 #define DEST_4F trans_4_GLint_4f_raw
341 #define DEST_4FN trans_4_GLint_4fn_raw
342 #define DEST_4UB trans_4_GLint_4ub_raw
343 #define DEST_4US trans_4_GLint_4us_raw
344 #include "m_trans_tmp.h"
345
346 #define SZ 3
347 #define INIT init_trans_3_GLint_raw
348 #define DEST_4F trans_3_GLint_4f_raw
349 #define DEST_4FN trans_3_GLint_4fn_raw
350 #define DEST_4UB trans_3_GLint_4ub_raw
351 #define DEST_4US trans_3_GLint_4us_raw
352 #define DEST_3FN trans_3_GLint_3fn_raw
353 #include "m_trans_tmp.h"
354
355 #define SZ 2
356 #define INIT init_trans_2_GLint_raw
357 #define DEST_4F trans_2_GLint_4f_raw
358 #define DEST_4FN trans_2_GLint_4fn_raw
359 #include "m_trans_tmp.h"
360
361 #define SZ 1
362 #define INIT init_trans_1_GLint_raw
363 #define DEST_4F trans_1_GLint_4f_raw
364 #define DEST_4FN trans_1_GLint_4fn_raw
365 #define DEST_1UB trans_1_GLint_1ub_raw
366 #define DEST_1UI trans_1_GLint_1ui_raw
367 #include "m_trans_tmp.h"
368
369
370 #undef SRC
371 #undef SRC_IDX
372 #undef TRX_3FN
373 #undef TRX_4F
374 #undef TRX_4FN
375 #undef TRX_UB
376 #undef TRX_US
377 #undef TRX_UI
378
379
380 /* GL_UNSIGNED_INT
381 */
382 #define SRC GLuint
383 #define SRC_IDX TYPE_IDX(GL_UNSIGNED_INT)
384 #define TRX_3FN(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
385 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
386 #define TRX_4FN(f,n) UINT_TO_FLOAT( PTR_ELT(f,n) )
387 #define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24)
388 #define TRX_US(us, f,n) us = (GLshort) (PTR_ELT(f,n) >> 16)
389 #define TRX_UI(f,n) PTR_ELT(f,n)
390
391
392 #define SZ 4
393 #define INIT init_trans_4_GLuint_raw
394 #define DEST_4F trans_4_GLuint_4f_raw
395 #define DEST_4FN trans_4_GLuint_4fn_raw
396 #define DEST_4UB trans_4_GLuint_4ub_raw
397 #define DEST_4US trans_4_GLuint_4us_raw
398 #include "m_trans_tmp.h"
399
400 #define SZ 3
401 #define INIT init_trans_3_GLuint_raw
402 #define DEST_4F trans_3_GLuint_4f_raw
403 #define DEST_4FN trans_3_GLuint_4fn_raw
404 #define DEST_4UB trans_3_GLuint_4ub_raw
405 #define DEST_4US trans_3_GLuint_4us_raw
406 #define DEST_3FN trans_3_GLuint_3fn_raw
407 #include "m_trans_tmp.h"
408
409 #define SZ 2
410 #define INIT init_trans_2_GLuint_raw
411 #define DEST_4F trans_2_GLuint_4f_raw
412 #define DEST_4FN trans_2_GLuint_4fn_raw
413 #include "m_trans_tmp.h"
414
415 #define SZ 1
416 #define INIT init_trans_1_GLuint_raw
417 #define DEST_4F trans_1_GLuint_4f_raw
418 #define DEST_4FN trans_1_GLuint_4fn_raw
419 #define DEST_1UB trans_1_GLuint_1ub_raw
420 #define DEST_1UI trans_1_GLuint_1ui_raw
421 #include "m_trans_tmp.h"
422
423 #undef SRC
424 #undef SRC_IDX
425 #undef TRX_3FN
426 #undef TRX_4F
427 #undef TRX_4FN
428 #undef TRX_UB
429 #undef TRX_US
430 #undef TRX_UI
431
432
433 /* GL_DOUBLE
434 */
435 #define SRC GLdouble
436 #define SRC_IDX TYPE_IDX(GL_DOUBLE)
437 #define TRX_3FN(f,n) (GLfloat) PTR_ELT(f,n)
438 #define TRX_4F(f,n) (GLfloat) PTR_ELT(f,n)
439 #define TRX_4FN(f,n) (GLfloat) PTR_ELT(f,n)
440 #define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_UBYTE(ub, PTR_ELT(f,n))
441 #define TRX_US(us,f,n) UNCLAMPED_FLOAT_TO_USHORT(us, PTR_ELT(f,n))
442 #define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n)
443 #define TRX_1F(f,n) (GLfloat) PTR_ELT(f,n)
444
445
446 #define SZ 4
447 #define INIT init_trans_4_GLdouble_raw
448 #define DEST_4F trans_4_GLdouble_4f_raw
449 #define DEST_4FN trans_4_GLdouble_4fn_raw
450 #define DEST_4UB trans_4_GLdouble_4ub_raw
451 #define DEST_4US trans_4_GLdouble_4us_raw
452 #include "m_trans_tmp.h"
453
454 #define SZ 3
455 #define INIT init_trans_3_GLdouble_raw
456 #define DEST_4F trans_3_GLdouble_4f_raw
457 #define DEST_4FN trans_3_GLdouble_4fn_raw
458 #define DEST_4UB trans_3_GLdouble_4ub_raw
459 #define DEST_4US trans_3_GLdouble_4us_raw
460 #define DEST_3FN trans_3_GLdouble_3fn_raw
461 #include "m_trans_tmp.h"
462
463 #define SZ 2
464 #define INIT init_trans_2_GLdouble_raw
465 #define DEST_4F trans_2_GLdouble_4f_raw
466 #define DEST_4FN trans_2_GLdouble_4fn_raw
467 #include "m_trans_tmp.h"
468
469 #define SZ 1
470 #define INIT init_trans_1_GLdouble_raw
471 #define DEST_4F trans_1_GLdouble_4f_raw
472 #define DEST_4FN trans_1_GLdouble_4fn_raw
473 #define DEST_1UB trans_1_GLdouble_1ub_raw
474 #define DEST_1UI trans_1_GLdouble_1ui_raw
475 #define DEST_1F trans_1_GLdouble_1f_raw
476 #include "m_trans_tmp.h"
477
478 #undef SRC
479 #undef SRC_IDX
480
481 /* GL_FLOAT
482 */
483 #define SRC GLfloat
484 #define SRC_IDX TYPE_IDX(GL_FLOAT)
485 #define SZ 4
486 #define INIT init_trans_4_GLfloat_raw
487 #define DEST_4UB trans_4_GLfloat_4ub_raw
488 #define DEST_4US trans_4_GLfloat_4us_raw
489 #define DEST_4F trans_4_GLfloat_4f_raw
490 #define DEST_4FN trans_4_GLfloat_4fn_raw
491 #include "m_trans_tmp.h"
492
493 #define SZ 3
494 #define INIT init_trans_3_GLfloat_raw
495 #define DEST_4F trans_3_GLfloat_4f_raw
496 #define DEST_4FN trans_3_GLfloat_4fn_raw
497 #define DEST_4UB trans_3_GLfloat_4ub_raw
498 #define DEST_4US trans_3_GLfloat_4us_raw
499 #define DEST_3FN trans_3_GLfloat_3fn_raw
500 #include "m_trans_tmp.h"
501
502 #define SZ 2
503 #define INIT init_trans_2_GLfloat_raw
504 #define DEST_4F trans_2_GLfloat_4f_raw
505 #define DEST_4FN trans_2_GLfloat_4fn_raw
506 #include "m_trans_tmp.h"
507
508 #define SZ 1
509 #define INIT init_trans_1_GLfloat_raw
510 #define DEST_4F trans_1_GLfloat_4f_raw
511 #define DEST_4FN trans_1_GLfloat_4fn_raw
512 #define DEST_1UB trans_1_GLfloat_1ub_raw
513 #define DEST_1UI trans_1_GLfloat_1ui_raw
514 #define DEST_1F trans_1_GLfloat_1f_raw
515
516 #include "m_trans_tmp.h"
517
518 #undef SRC
519 #undef SRC_IDX
520 #undef TRX_3FN
521 #undef TRX_4F
522 #undef TRX_4FN
523 #undef TRX_UB
524 #undef TRX_US
525 #undef TRX_UI
526
527
528 static void trans_4_GLubyte_4ub_raw(GLubyte (*t)[4],
529 CONST void *Ptr,
530 GLuint stride,
531 ARGS )
532 {
533 const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride;
534 GLuint i;
535
536 if (((((uintptr_t) f | (uintptr_t) stride)) & 3L) == 0L) {
537 /* Aligned.
538 */
539 for (i = DST_START ; i < n ; i++, f += stride) {
540 COPY_4UBV( t[i], f );
541 }
542 } else {
543 for (i = DST_START ; i < n ; i++, f += stride) {
544 t[i][0] = f[0];
545 t[i][1] = f[1];
546 t[i][2] = f[2];
547 t[i][3] = f[3];
548 }
549 }
550 }
551
552
553 static void init_translate_raw(void)
554 {
555 memset( TAB(_1ui), 0, sizeof(TAB(_1ui)) );
556 memset( TAB(_1ub), 0, sizeof(TAB(_1ub)) );
557 memset( TAB(_3fn), 0, sizeof(TAB(_3fn)) );
558 memset( TAB(_4ub), 0, sizeof(TAB(_4ub)) );
559 memset( TAB(_4us), 0, sizeof(TAB(_4us)) );
560 memset( TAB(_4f), 0, sizeof(TAB(_4f)) );
561 memset( TAB(_4fn), 0, sizeof(TAB(_4fn)) );
562
563 init_trans_4_GLbyte_raw();
564 init_trans_3_GLbyte_raw();
565 init_trans_2_GLbyte_raw();
566 init_trans_1_GLbyte_raw();
567 init_trans_1_GLubyte_raw();
568 init_trans_3_GLubyte_raw();
569 init_trans_4_GLubyte_raw();
570 init_trans_4_GLshort_raw();
571 init_trans_3_GLshort_raw();
572 init_trans_2_GLshort_raw();
573 init_trans_1_GLshort_raw();
574 init_trans_4_GLushort_raw();
575 init_trans_3_GLushort_raw();
576 init_trans_2_GLushort_raw();
577 init_trans_1_GLushort_raw();
578 init_trans_4_GLint_raw();
579 init_trans_3_GLint_raw();
580 init_trans_2_GLint_raw();
581 init_trans_1_GLint_raw();
582 init_trans_4_GLuint_raw();
583 init_trans_3_GLuint_raw();
584 init_trans_2_GLuint_raw();
585 init_trans_1_GLuint_raw();
586 init_trans_4_GLdouble_raw();
587 init_trans_3_GLdouble_raw();
588 init_trans_2_GLdouble_raw();
589 init_trans_1_GLdouble_raw();
590 init_trans_4_GLfloat_raw();
591 init_trans_3_GLfloat_raw();
592 init_trans_2_GLfloat_raw();
593 init_trans_1_GLfloat_raw();
594
595 TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub_raw;
596 }
597
598
599 #undef TAB
600 #ifdef CLASS
601 #undef CLASS
602 #endif
603 #undef ARGS
604 #undef CHECK
605 #undef SRC_START
606 #undef DST_START
607 #undef NEXT_F
608 #undef NEXT_F2
609
610
611
612
613
614 void _math_init_translate( void )
615 {
616 init_translate_raw();
617 }
618
619
620 /**
621 * Translate vector of values to GLfloat [1].
622 */
623 void _math_trans_1f(GLfloat *to,
624 CONST void *ptr,
625 GLuint stride,
626 GLenum type,
627 GLuint start,
628 GLuint n )
629 {
630 _math_trans_1f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
631 }
632
633 /**
634 * Translate vector of values to GLuint [1].
635 */
636 void _math_trans_1ui(GLuint *to,
637 CONST void *ptr,
638 GLuint stride,
639 GLenum type,
640 GLuint start,
641 GLuint n )
642 {
643 _math_trans_1ui_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
644 }
645
646 /**
647 * Translate vector of values to GLubyte [1].
648 */
649 void _math_trans_1ub(GLubyte *to,
650 CONST void *ptr,
651 GLuint stride,
652 GLenum type,
653 GLuint start,
654 GLuint n )
655 {
656 _math_trans_1ub_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
657 }
658
659
660 /**
661 * Translate vector of values to GLubyte [4].
662 */
663 void _math_trans_4ub(GLubyte (*to)[4],
664 CONST void *ptr,
665 GLuint stride,
666 GLenum type,
667 GLuint size,
668 GLuint start,
669 GLuint n )
670 {
671 _math_trans_4ub_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
672 }
673
674 /**
675 * Translate vector of values to GLchan [4].
676 */
677 void _math_trans_4chan( GLchan (*to)[4],
678 CONST void *ptr,
679 GLuint stride,
680 GLenum type,
681 GLuint size,
682 GLuint start,
683 GLuint n )
684 {
685 #if CHAN_TYPE == GL_UNSIGNED_BYTE
686 _math_trans_4ub( to, ptr, stride, type, size, start, n );
687 #elif CHAN_TYPE == GL_UNSIGNED_SHORT
688 _math_trans_4us( to, ptr, stride, type, size, start, n );
689 #elif CHAN_TYPE == GL_FLOAT
690 _math_trans_4fn( to, ptr, stride, type, size, start, n );
691 #endif
692 }
693
694 /**
695 * Translate vector of values to GLushort [4].
696 */
697 void _math_trans_4us(GLushort (*to)[4],
698 CONST void *ptr,
699 GLuint stride,
700 GLenum type,
701 GLuint size,
702 GLuint start,
703 GLuint n )
704 {
705 _math_trans_4us_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
706 }
707
708 /**
709 * Translate vector of values to GLfloat [4].
710 */
711 void _math_trans_4f(GLfloat (*to)[4],
712 CONST void *ptr,
713 GLuint stride,
714 GLenum type,
715 GLuint size,
716 GLuint start,
717 GLuint n )
718 {
719 _math_trans_4f_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
720 }
721
722 /**
723 * Translate vector of values to GLfloat[4], normalized to [-1, 1].
724 */
725 void _math_trans_4fn(GLfloat (*to)[4],
726 CONST void *ptr,
727 GLuint stride,
728 GLenum type,
729 GLuint size,
730 GLuint start,
731 GLuint n )
732 {
733 _math_trans_4fn_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
734 }
735
736 /**
737 * Translate vector of values to GLfloat[3], normalized to [-1, 1].
738 */
739 void _math_trans_3fn(GLfloat (*to)[3],
740 CONST void *ptr,
741 GLuint stride,
742 GLenum type,
743 GLuint start,
744 GLuint n )
745 {
746 _math_trans_3fn_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
747 }