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