2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
26 * New (3.1) transformation code written by Keith Whitwell.
30 /* KW: This file also included by tnl/trans_elt.c to build code
31 * specific to the implementation of array-elements in the
37 static void DEST_4F( GLfloat (*t
)[4],
42 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
43 const GLubyte
*first
= f
;
48 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
51 if (SZ
>= 1) t
[i
][0] = TRX_4F(f
, 0);
52 if (SZ
>= 2) t
[i
][1] = TRX_4F(f
, 1);
53 if (SZ
>= 3) t
[i
][2] = TRX_4F(f
, 2);
54 if (SZ
== 4) t
[i
][3] = TRX_4F(f
, 3); else t
[i
][3] = 1.0;
62 static void DEST_3F( GLfloat (*t
)[3],
67 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
68 const GLubyte
*first
= f
;
72 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
75 t
[i
][0] = TRX_3F(f
, 0);
76 t
[i
][1] = TRX_3F(f
, 1);
77 t
[i
][2] = TRX_3F(f
, 2);
84 static void DEST_1F( GLfloat
*t
,
89 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
90 const GLubyte
*first
= f
;
94 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
104 static void DEST_4UB( GLubyte (*t
)[4],
109 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
110 const GLubyte
*first
= f
;
114 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
117 if (SZ
>= 1) TRX_UB(t
[i
][0], f
, 0);
118 if (SZ
>= 2) TRX_UB(t
[i
][1], f
, 1);
119 if (SZ
>= 3) TRX_UB(t
[i
][2], f
, 2);
120 if (SZ
== 4) TRX_UB(t
[i
][3], f
, 3); else t
[i
][3] = 255;
128 static void DEST_4US( GLushort (*t
)[4],
133 const GLubyte
*f
= (GLubyte
*) ((GLubyte
*) ptr
+ SRC_START
* stride
);
134 const GLubyte
*first
= f
;
138 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
141 if (SZ
>= 1) TRX_US(t
[i
][0], f
, 0);
142 if (SZ
>= 2) TRX_US(t
[i
][1], f
, 1);
143 if (SZ
>= 3) TRX_US(t
[i
][2], f
, 2);
144 if (SZ
== 4) TRX_US(t
[i
][3], f
, 3); else t
[i
][3] = 65535;
152 static void DEST_1UB( GLubyte
*t
,
157 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
158 const GLubyte
*first
= f
;
162 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
173 static void DEST_1UI( GLuint
*t
,
178 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
179 const GLubyte
*first
= f
;
184 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
194 static void INIT(void)
198 TAB(_1ui
)[SRC_IDX
] = DEST_1UI
;
202 TAB(_1ub
)[SRC_IDX
] = DEST_1UB
;
206 TAB(_1f
)[SRC_IDX
] = DEST_1F
;
210 TAB(_3f
)[SRC_IDX
] = DEST_3F
;
213 TAB(_4ub
)[SZ
][SRC_IDX
] = DEST_4UB
;
216 TAB(_4us
)[SZ
][SRC_IDX
] = DEST_4US
;
219 TAB(_4f
)[SZ
][SRC_IDX
] = DEST_4F
;