0e9f666472f01735669d07f998c3128669e06bc5
2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
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:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
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.
26 * \brief Templates for vector conversions.
27 * \author Keith Whitwell.
31 static void DEST_4F( GLfloat (*t
)[4],
36 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
37 const GLubyte
*first
= f
;
42 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
44 if (SZ
>= 1) t
[i
][0] = TRX_4F(f
, 0);
45 if (SZ
>= 2) t
[i
][1] = TRX_4F(f
, 1);
46 if (SZ
>= 3) t
[i
][2] = TRX_4F(f
, 2);
47 if (SZ
== 4) t
[i
][3] = TRX_4F(f
, 3); else t
[i
][3] = 1.0;
55 static void DEST_4FN( GLfloat (*t
)[4],
60 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
61 const GLubyte
*first
= f
;
66 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
68 if (SZ
>= 1) t
[i
][0] = TRX_4FN(f
, 0);
69 if (SZ
>= 2) t
[i
][1] = TRX_4FN(f
, 1);
70 if (SZ
>= 3) t
[i
][2] = TRX_4FN(f
, 2);
71 if (SZ
== 4) t
[i
][3] = TRX_4FN(f
, 3); else t
[i
][3] = 1.0;
78 static void DEST_3FN( GLfloat (*t
)[3],
83 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
84 const GLubyte
*first
= f
;
88 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
90 t
[i
][0] = TRX_3FN(f
, 0);
91 t
[i
][1] = TRX_3FN(f
, 1);
92 t
[i
][2] = TRX_3FN(f
, 2);
98 static void DEST_1F( GLfloat
*t
,
103 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
104 const GLubyte
*first
= f
;
108 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
116 static void DEST_4UB( GLubyte (*t
)[4],
121 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
122 const GLubyte
*first
= f
;
126 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
128 if (SZ
>= 1) TRX_UB(t
[i
][0], f
, 0);
129 if (SZ
>= 2) TRX_UB(t
[i
][1], f
, 1);
130 if (SZ
>= 3) TRX_UB(t
[i
][2], f
, 2);
131 if (SZ
== 4) TRX_UB(t
[i
][3], f
, 3); else t
[i
][3] = 255;
138 static void DEST_4US( GLushort (*t
)[4],
143 const GLubyte
*f
= (GLubyte
*) ((GLubyte
*) ptr
+ SRC_START
* stride
);
144 const GLubyte
*first
= f
;
148 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
150 if (SZ
>= 1) TRX_US(t
[i
][0], f
, 0);
151 if (SZ
>= 2) TRX_US(t
[i
][1], f
, 1);
152 if (SZ
>= 3) TRX_US(t
[i
][2], f
, 2);
153 if (SZ
== 4) TRX_US(t
[i
][3], f
, 3); else t
[i
][3] = 65535;
160 static void DEST_1UB( GLubyte
*t
,
165 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
166 const GLubyte
*first
= f
;
170 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
179 static void DEST_1UI( GLuint
*t
,
184 const GLubyte
*f
= (GLubyte
*) ptr
+ SRC_START
* stride
;
185 const GLubyte
*first
= f
;
190 for (i
= DST_START
; i
< n
; i
++, NEXT_F
) {
198 static void INIT(void)
202 TAB(_1ui
)[SRC_IDX
] = DEST_1UI
;
206 TAB(_1ub
)[SRC_IDX
] = DEST_1UB
;
210 TAB(_1f
)[SRC_IDX
] = DEST_1F
;
214 TAB(_3fn
)[SRC_IDX
] = DEST_3FN
;
217 TAB(_4ub
)[SZ
][SRC_IDX
] = DEST_4UB
;
220 TAB(_4us
)[SZ
][SRC_IDX
] = DEST_4US
;
223 TAB(_4f
)[SZ
][SRC_IDX
] = DEST_4F
;
226 TAB(_4fn
)[SZ
][SRC_IDX
] = DEST_4FN
;