blob: 0eb2ee8281fc110ebd3dcdd65e16b7356f346827 [file] [log] [blame]
Brian Paul74b493a2001-01-24 00:04:58 +00001/* $Id: m_translate.c,v 1.4 2001/01/24 00:04:59 brianp Exp $ */
Keith Whitwell23caf202000-11-16 21:05:34 +00002
3/*
4 * Mesa 3-D graphics library
Brian Paul74b493a2001-01-24 00:04:58 +00005 * Version: 3.5
Keith Whitwell23caf202000-11-16 21:05:34 +00006 *
Brian Paul74b493a2001-01-24 00:04:58 +00007 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
Keith Whitwell23caf202000-11-16 21:05:34 +00008 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27/*
28 * New (3.1) transformation code written by Keith Whitwell.
29 */
30
31
32#include "glheader.h"
33#include "colormac.h"
34#include "mem.h"
35#include "mmath.h"
36
37#include "m_translate.h"
38
Keith Whitwellcab974c2000-12-26 05:09:27 +000039
40
41typedef void (*trans_1f_func)(GLfloat *to,
42 CONST void *ptr,
43 GLuint stride,
44 GLuint start,
45 GLuint n );
46
47typedef void (*trans_1ui_func)(GLuint *to,
48 CONST void *ptr,
49 GLuint stride,
50 GLuint start,
51 GLuint n );
52
53typedef void (*trans_1ub_func)(GLubyte *to,
54 CONST void *ptr,
55 GLuint stride,
56 GLuint start,
57 GLuint n );
58
59typedef void (*trans_4ub_func)(GLubyte (*to)[4],
Brian Paul74b493a2001-01-24 00:04:58 +000060 CONST void *ptr,
61 GLuint stride,
62 GLuint start,
63 GLuint n );
64
65typedef void (*trans_4us_func)(GLushort (*to)[4],
66 CONST void *ptr,
67 GLuint stride,
68 GLuint start,
69 GLuint n );
Keith Whitwellcab974c2000-12-26 05:09:27 +000070
71typedef void (*trans_4f_func)(GLfloat (*to)[4],
72 CONST void *ptr,
73 GLuint stride,
74 GLuint start,
75 GLuint n );
76
77typedef void (*trans_3f_func)(GLfloat (*to)[3],
78 CONST void *ptr,
79 GLuint stride,
80 GLuint start,
81 GLuint n );
82
83
84
85
86#define TYPE_IDX(t) ((t) & 0xf)
87#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
88
89
Keith Whitwell23caf202000-11-16 21:05:34 +000090/* This macro is used on other systems, so undefine it for this module */
91
92#undef CHECK
93
Keith Whitwellcab974c2000-12-26 05:09:27 +000094static trans_1f_func _math_trans_1f_tab[MAX_TYPES];
95static trans_1ui_func _math_trans_1ui_tab[MAX_TYPES];
96static trans_1ub_func _math_trans_1ub_tab[MAX_TYPES];
97static trans_3f_func _math_trans_3f_tab[MAX_TYPES];
98static trans_4ub_func _math_trans_4ub_tab[5][MAX_TYPES];
Brian Paul74b493a2001-01-24 00:04:58 +000099static trans_4us_func _math_trans_4us_tab[5][MAX_TYPES];
Keith Whitwellcab974c2000-12-26 05:09:27 +0000100static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES];
Keith Whitwell23caf202000-11-16 21:05:34 +0000101
102
103#define PTR_ELT(ptr, elt) (((SRC *)ptr)[elt])
104
105
Keith Whitwellcab974c2000-12-26 05:09:27 +0000106#define TAB(x) _math_trans##x##_tab
Keith Whitwell23caf202000-11-16 21:05:34 +0000107#define ARGS GLuint start, GLuint n
108#define SRC_START start
109#define DST_START 0
110#define STRIDE stride
111#define NEXT_F f += stride
112#define NEXT_F2
113#define CHECK
114
115
116
117
118/* GL_BYTE
119 */
120#define SRC GLbyte
121#define SRC_IDX TYPE_IDX(GL_BYTE)
122#define TRX_3F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
123#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
124#define TRX_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) )
Brian Paul74b493a2001-01-24 00:04:58 +0000125#define TRX_US(ch, f,n) ch = BYTE_TO_USHORT( PTR_ELT(f,n) )
Keith Whitwell23caf202000-11-16 21:05:34 +0000126#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
127
128
129#define SZ 4
130#define INIT init_trans_4_GLbyte_raw
131#define DEST_4F trans_4_GLbyte_4f_raw
132#define DEST_4UB trans_4_GLbyte_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000133#define DEST_4US trans_4_GLbyte_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000134#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_4UB trans_3_GLbyte_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000140#define DEST_4US trans_3_GLbyte_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000141#define DEST_3F trans_3_GLbyte_3f_raw
142#include "m_trans_tmp.h"
143
144#define SZ 2
145#define INIT init_trans_2_GLbyte_raw
146#define DEST_4F trans_2_GLbyte_4f_raw
147#include "m_trans_tmp.h"
148
149#define SZ 1
150#define INIT init_trans_1_GLbyte_raw
151#define DEST_4F trans_1_GLbyte_4f_raw
152#define DEST_1UB trans_1_GLbyte_1ub_raw
153#define DEST_1UI trans_1_GLbyte_1ui_raw
154#include "m_trans_tmp.h"
155
156#undef SRC
157#undef TRX_3F
158#undef TRX_4F
159#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000160#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000161#undef TRX_UI
162#undef SRC_IDX
163
Brian Paul74b493a2001-01-24 00:04:58 +0000164
Keith Whitwell23caf202000-11-16 21:05:34 +0000165/* GL_UNSIGNED_BYTE
166 */
167#define SRC GLubyte
168#define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE)
169#define TRX_3F(f,n) /* unused */
170#define TRX_4F(f,n) /* unused */
171#define TRX_UB(ub, f,n) ub = PTR_ELT(f,n)
Brian Paul74b493a2001-01-24 00:04:58 +0000172#define TRX_US(us, f,n) us = UBYTE_TO_USHORT(PTR_ELT(f,n))
Keith Whitwell23caf202000-11-16 21:05:34 +0000173#define TRX_UI(f,n) (GLuint)PTR_ELT(f,n)
174
175/* 4ub->4ub handled in special case below.
176 */
177
178#define SZ 3
179#define INIT init_trans_3_GLubyte_raw
180#define DEST_4UB trans_3_GLubyte_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000181#define DEST_4US trans_3_GLubyte_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000182#include "m_trans_tmp.h"
183
184
185#define SZ 1
186#define INIT init_trans_1_GLubyte_raw
187#define DEST_1UI trans_1_GLubyte_1ui_raw
188#define DEST_1UB trans_1_GLubyte_1ub_raw
189#include "m_trans_tmp.h"
190
191#undef SRC
192#undef SRC_IDX
193#undef TRX_3F
194#undef TRX_4F
195#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000196#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000197#undef TRX_UI
198
199
200/* GL_SHORT
201 */
202#define SRC GLshort
203#define SRC_IDX TYPE_IDX(GL_SHORT)
204#define TRX_3F(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) )
205#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
206#define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n))
Brian Paul74b493a2001-01-24 00:04:58 +0000207#define TRX_US(us, f,n) us = SHORT_TO_USHORT(PTR_ELT(f,n))
Keith Whitwell23caf202000-11-16 21:05:34 +0000208#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
209
210
211#define SZ 4
212#define INIT init_trans_4_GLshort_raw
213#define DEST_4F trans_4_GLshort_4f_raw
214#define DEST_4UB trans_4_GLshort_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000215#define DEST_4US trans_4_GLshort_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000216#include "m_trans_tmp.h"
217
218#define SZ 3
219#define INIT init_trans_3_GLshort_raw
220#define DEST_4F trans_3_GLshort_4f_raw
221#define DEST_4UB trans_3_GLshort_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000222#define DEST_4US trans_3_GLshort_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000223#define DEST_3F trans_3_GLshort_3f_raw
224#include "m_trans_tmp.h"
225
226#define SZ 2
227#define INIT init_trans_2_GLshort_raw
228#define DEST_4F trans_2_GLshort_4f_raw
229#include "m_trans_tmp.h"
230
231#define SZ 1
232#define INIT init_trans_1_GLshort_raw
233#define DEST_4F trans_1_GLshort_4f_raw
234#define DEST_1UB trans_1_GLshort_1ub_raw
235#define DEST_1UI trans_1_GLshort_1ui_raw
236#include "m_trans_tmp.h"
237
238
239#undef SRC
240#undef SRC_IDX
241#undef TRX_3F
242#undef TRX_4F
243#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000244#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000245#undef TRX_UI
246
247
248/* GL_UNSIGNED_SHORT
249 */
250#define SRC GLushort
251#define SRC_IDX TYPE_IDX(GL_UNSIGNED_SHORT)
252#define TRX_3F(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) )
253#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
254#define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8)
Brian Paul74b493a2001-01-24 00:04:58 +0000255#define TRX_US(us,f,n) us = (GLushort) (PTR_ELT(f,n) >> 8)
Keith Whitwell23caf202000-11-16 21:05:34 +0000256#define TRX_UI(f,n) (GLuint) PTR_ELT(f,n)
257
258
259#define SZ 4
260#define INIT init_trans_4_GLushort_raw
261#define DEST_4F trans_4_GLushort_4f_raw
262#define DEST_4UB trans_4_GLushort_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000263#define DEST_4US trans_4_GLushort_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000264#include "m_trans_tmp.h"
265
266#define SZ 3
267#define INIT init_trans_3_GLushort_raw
268#define DEST_4F trans_3_GLushort_4f_raw
269#define DEST_4UB trans_3_GLushort_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000270#define DEST_4US trans_3_GLushort_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000271#define DEST_3F trans_3_GLushort_3f_raw
272#include "m_trans_tmp.h"
273
274#define SZ 2
275#define INIT init_trans_2_GLushort_raw
276#define DEST_4F trans_2_GLushort_4f_raw
277#include "m_trans_tmp.h"
278
279#define SZ 1
280#define INIT init_trans_1_GLushort_raw
281#define DEST_4F trans_1_GLushort_4f_raw
282#define DEST_1UB trans_1_GLushort_1ub_raw
283#define DEST_1UI trans_1_GLushort_1ui_raw
284#include "m_trans_tmp.h"
285
286#undef SRC
287#undef SRC_IDX
288#undef TRX_3F
289#undef TRX_4F
290#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000291#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000292#undef TRX_UI
293
294
295/* GL_INT
296 */
297#define SRC GLint
298#define SRC_IDX TYPE_IDX(GL_INT)
299#define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
300#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
301#define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n))
Brian Paul74b493a2001-01-24 00:04:58 +0000302#define TRX_US(us, f,n) us = INT_TO_USHORT(PTR_ELT(f,n))
Keith Whitwell23caf202000-11-16 21:05:34 +0000303#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
304
305
306#define SZ 4
307#define INIT init_trans_4_GLint_raw
308#define DEST_4F trans_4_GLint_4f_raw
309#define DEST_4UB trans_4_GLint_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000310#define DEST_4US trans_4_GLint_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000311#include "m_trans_tmp.h"
312
313#define SZ 3
314#define INIT init_trans_3_GLint_raw
315#define DEST_4F trans_3_GLint_4f_raw
316#define DEST_4UB trans_3_GLint_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000317#define DEST_4US trans_3_GLint_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000318#define DEST_3F trans_3_GLint_3f_raw
319#include "m_trans_tmp.h"
320
321#define SZ 2
322#define INIT init_trans_2_GLint_raw
323#define DEST_4F trans_2_GLint_4f_raw
324#include "m_trans_tmp.h"
325
326#define SZ 1
327#define INIT init_trans_1_GLint_raw
328#define DEST_4F trans_1_GLint_4f_raw
329#define DEST_1UB trans_1_GLint_1ub_raw
330#define DEST_1UI trans_1_GLint_1ui_raw
331#include "m_trans_tmp.h"
332
333
334#undef SRC
335#undef SRC_IDX
336#undef TRX_3F
337#undef TRX_4F
338#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000339#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000340#undef TRX_UI
341
342
343/* GL_UNSIGNED_INT
344 */
345#define SRC GLuint
346#define SRC_IDX TYPE_IDX(GL_UNSIGNED_INT)
347#define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
348#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
349#define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24)
Brian Paul74b493a2001-01-24 00:04:58 +0000350#define TRX_US(us, f,n) us = (GLshort) (PTR_ELT(f,n) >> 16)
Keith Whitwell23caf202000-11-16 21:05:34 +0000351#define TRX_UI(f,n) PTR_ELT(f,n)
352
353
354#define SZ 4
355#define INIT init_trans_4_GLuint_raw
356#define DEST_4F trans_4_GLuint_4f_raw
357#define DEST_4UB trans_4_GLuint_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000358#define DEST_4US trans_4_GLuint_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000359#include "m_trans_tmp.h"
360
361#define SZ 3
362#define INIT init_trans_3_GLuint_raw
363#define DEST_4F trans_3_GLuint_4f_raw
364#define DEST_4UB trans_3_GLuint_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000365#define DEST_4US trans_3_GLuint_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000366#define DEST_3F trans_3_GLuint_3f_raw
367#include "m_trans_tmp.h"
368
369#define SZ 2
370#define INIT init_trans_2_GLuint_raw
371#define DEST_4F trans_2_GLuint_4f_raw
372#include "m_trans_tmp.h"
373
374#define SZ 1
375#define INIT init_trans_1_GLuint_raw
376#define DEST_4F trans_1_GLuint_4f_raw
377#define DEST_1UB trans_1_GLuint_1ub_raw
378#define DEST_1UI trans_1_GLuint_1ui_raw
379#include "m_trans_tmp.h"
380
381#undef SRC
382#undef SRC_IDX
383#undef TRX_3F
384#undef TRX_4F
385#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000386#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000387#undef TRX_UI
388
389
390/* GL_DOUBLE
391 */
392#define SRC GLdouble
393#define SRC_IDX TYPE_IDX(GL_DOUBLE)
394#define TRX_3F(f,n) PTR_ELT(f,n)
395#define TRX_4F(f,n) PTR_ELT(f,n)
Brian Paul74b493a2001-01-24 00:04:58 +0000396#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_UBYTE(ub, PTR_ELT(f,n))
397#define TRX_US(us,f,n) UNCLAMPED_FLOAT_TO_USHORT(us, PTR_ELT(f,n))
Keith Whitwell23caf202000-11-16 21:05:34 +0000398#define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n)
399#define TRX_1F(f,n) PTR_ELT(f,n)
400
401
402#define SZ 4
403#define INIT init_trans_4_GLdouble_raw
404#define DEST_4F trans_4_GLdouble_4f_raw
405#define DEST_4UB trans_4_GLdouble_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000406#define DEST_4US trans_4_GLdouble_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000407#include "m_trans_tmp.h"
408
409#define SZ 3
410#define INIT init_trans_3_GLdouble_raw
411#define DEST_4F trans_3_GLdouble_4f_raw
412#define DEST_4UB trans_3_GLdouble_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000413#define DEST_4US trans_3_GLdouble_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000414#define DEST_3F trans_3_GLdouble_3f_raw
415#include "m_trans_tmp.h"
416
417#define SZ 2
418#define INIT init_trans_2_GLdouble_raw
419#define DEST_4F trans_2_GLdouble_4f_raw
420#include "m_trans_tmp.h"
421
422#define SZ 1
423#define INIT init_trans_1_GLdouble_raw
424#define DEST_4F trans_1_GLdouble_4f_raw
425#define DEST_1UB trans_1_GLdouble_1ub_raw
426#define DEST_1UI trans_1_GLdouble_1ui_raw
427#define DEST_1F trans_1_GLdouble_1f_raw
428#include "m_trans_tmp.h"
429
430#undef SRC
431#undef SRC_IDX
432
433/* GL_FLOAT
434 */
435#define SRC GLfloat
436#define SRC_IDX TYPE_IDX(GL_FLOAT)
437#define SZ 4
438#define INIT init_trans_4_GLfloat_raw
439#define DEST_4UB trans_4_GLfloat_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000440#define DEST_4US trans_4_GLfloat_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000441#define DEST_4F trans_4_GLfloat_4f_raw
442#include "m_trans_tmp.h"
443
444#define SZ 3
445#define INIT init_trans_3_GLfloat_raw
446#define DEST_4F trans_3_GLfloat_4f_raw
447#define DEST_4UB trans_3_GLfloat_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000448#define DEST_4US trans_3_GLfloat_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000449#define DEST_3F trans_3_GLfloat_3f_raw
450#include "m_trans_tmp.h"
451
452#define SZ 2
453#define INIT init_trans_2_GLfloat_raw
454#define DEST_4F trans_2_GLfloat_4f_raw
455#include "m_trans_tmp.h"
456
457#define SZ 1
458#define INIT init_trans_1_GLfloat_raw
459#define DEST_4F trans_1_GLfloat_4f_raw
460#define DEST_1UB trans_1_GLfloat_1ub_raw
461#define DEST_1UI trans_1_GLfloat_1ui_raw
462#define DEST_1F trans_1_GLfloat_1f_raw
463
464#include "m_trans_tmp.h"
465
466#undef SRC
467#undef SRC_IDX
468#undef TRX_3F
469#undef TRX_4F
470#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000471#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000472#undef TRX_UI
473
474
Brian Paul74b493a2001-01-24 00:04:58 +0000475static void trans_4_GLubyte_4ub_raw(GLubyte (*t)[4],
476 CONST void *Ptr,
477 GLuint stride,
478 ARGS )
Keith Whitwell23caf202000-11-16 21:05:34 +0000479{
480 const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride;
481 GLuint i;
482
483 if (((((long) f | (long) stride)) & 3L) == 0L) {
484 /* Aligned.
485 */
486 for (i = DST_START ; i < n ; i++, f += stride) {
487 COPY_4UBV( t[i], f );
488 }
489 } else {
490 for (i = DST_START ; i < n ; i++, f += stride) {
491 t[i][0] = f[0];
492 t[i][1] = f[1];
493 t[i][2] = f[2];
494 t[i][3] = f[3];
495 }
496 }
497}
498
499
500static void init_translate_raw(void)
501{
502 MEMSET( TAB(_1ui), 0, sizeof(TAB(_1ui)) );
503 MEMSET( TAB(_1ub), 0, sizeof(TAB(_1ub)) );
504 MEMSET( TAB(_3f), 0, sizeof(TAB(_3f)) );
505 MEMSET( TAB(_4ub), 0, sizeof(TAB(_4ub)) );
Brian Paul74b493a2001-01-24 00:04:58 +0000506 MEMSET( TAB(_4us), 0, sizeof(TAB(_4us)) );
Keith Whitwell23caf202000-11-16 21:05:34 +0000507 MEMSET( TAB(_4f), 0, sizeof(TAB(_4f)) );
508
509 TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub_raw;
510
511 init_trans_4_GLbyte_raw();
512 init_trans_3_GLbyte_raw();
513 init_trans_2_GLbyte_raw();
514 init_trans_1_GLbyte_raw();
515 init_trans_1_GLubyte_raw();
516 init_trans_3_GLubyte_raw();
517 init_trans_4_GLshort_raw();
518 init_trans_3_GLshort_raw();
519 init_trans_2_GLshort_raw();
520 init_trans_1_GLshort_raw();
521 init_trans_4_GLushort_raw();
522 init_trans_3_GLushort_raw();
523 init_trans_2_GLushort_raw();
524 init_trans_1_GLushort_raw();
525 init_trans_4_GLint_raw();
526 init_trans_3_GLint_raw();
527 init_trans_2_GLint_raw();
528 init_trans_1_GLint_raw();
529 init_trans_4_GLuint_raw();
530 init_trans_3_GLuint_raw();
531 init_trans_2_GLuint_raw();
532 init_trans_1_GLuint_raw();
533 init_trans_4_GLdouble_raw();
534 init_trans_3_GLdouble_raw();
535 init_trans_2_GLdouble_raw();
536 init_trans_1_GLdouble_raw();
537 init_trans_4_GLfloat_raw();
538 init_trans_3_GLfloat_raw();
539 init_trans_2_GLfloat_raw();
540 init_trans_1_GLfloat_raw();
541}
542
543
544#undef TAB
545#undef CLASS
546#undef ARGS
547#undef CHECK
548#undef SRC_START
549#undef DST_START
550#undef NEXT_F
551#undef NEXT_F2
552
553
554
555
556
Keith Whitwellcab974c2000-12-26 05:09:27 +0000557void _math_init_translate( void )
Keith Whitwell23caf202000-11-16 21:05:34 +0000558{
559 init_translate_raw();
560}
Keith Whitwellcab974c2000-12-26 05:09:27 +0000561
562
563
564void _math_trans_1f(GLfloat *to,
565 CONST void *ptr,
566 GLuint stride,
567 GLenum type,
568 GLuint start,
569 GLuint n )
570{
571 _math_trans_1f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
572}
573
574void _math_trans_1ui(GLuint *to,
575 CONST void *ptr,
576 GLuint stride,
577 GLenum type,
578 GLuint start,
579 GLuint n )
580{
581 _math_trans_1ui_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
582}
583
584void _math_trans_1ub(GLubyte *to,
585 CONST void *ptr,
586 GLuint stride,
587 GLenum type,
588 GLuint start,
589 GLuint n )
590{
591 _math_trans_1ub_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
592}
593
594
595void _math_trans_4ub(GLubyte (*to)[4],
596 CONST void *ptr,
597 GLuint stride,
598 GLenum type,
599 GLuint size,
600 GLuint start,
601 GLuint n )
602{
603 _math_trans_4ub_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
604}
605
Brian Paul74b493a2001-01-24 00:04:58 +0000606void _math_trans_4us(GLushort (*to)[4],
607 CONST void *ptr,
608 GLuint stride,
609 GLenum type,
610 GLuint size,
611 GLuint start,
612 GLuint n )
613{
614 _math_trans_4us_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
615}
616
Keith Whitwellcab974c2000-12-26 05:09:27 +0000617void _math_trans_4f(GLfloat (*to)[4],
618 CONST void *ptr,
619 GLuint stride,
620 GLenum type,
621 GLuint size,
622 GLuint start,
623 GLuint n )
624{
625 _math_trans_4f_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
626}
627
628void _math_trans_3f(GLfloat (*to)[3],
629 CONST void *ptr,
630 GLuint stride,
631 GLenum type,
632 GLuint start,
633 GLuint n )
634{
635 _math_trans_3f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
636}
637