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.
31 * This template file generates texel fetch functions for 1-D, 2-D and 3-D
38 #define CHAN_SRC( t, i, j, k, sz ) \
39 ((GLchan *)(t)->Data + (i) * (sz))
40 #define UBYTE_SRC( t, i, j, k, sz ) \
41 ((GLubyte *)(t)->Data + (i) * (sz))
42 #define USHORT_SRC( t, i, j, k ) \
43 ((GLushort *)(t)->Data + (i))
44 #define FLOAT_SRC( t, i, j, k ) \
45 ((GLfloat *)(t)->Data + (i))
47 #define FETCH(x) fetch_1d_texel_##x
51 #define CHAN_SRC( t, i, j, k, sz ) \
52 ((GLchan *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz))
53 #define UBYTE_SRC( t, i, j, k, sz ) \
54 ((GLubyte *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz))
55 #define USHORT_SRC( t, i, j, k ) \
56 ((GLushort *)(t)->Data + ((t)->RowStride * (j) + (i)))
57 #define FLOAT_SRC( t, i, j, k ) \
58 ((GLfloat *)(t)->Data + ((t)->RowStride * (j) + (i)))
60 #define FETCH(x) fetch_2d_texel_##x
64 #define CHAN_SRC( t, i, j, k, sz ) \
65 (GLchan *)(t)->Data + (((t)->Height * (k) + (j)) * \
66 (t)->RowStride + (i)) * (sz)
67 #define UBYTE_SRC( t, i, j, k, sz ) \
68 ((GLubyte *)(t)->Data + (((t)->Height * (k) + (j)) * \
69 (t)->RowStride + (i)) * (sz))
70 #define USHORT_SRC( t, i, j, k ) \
71 ((GLushort *)(t)->Data + (((t)->Height * (k) + (j)) * \
72 (t)->RowStride + (i)))
73 #define FLOAT_SRC( t, i, j, k ) \
74 ((GLfloat *)(t)->Data + (((t)->Height * (k) + (j)) * \
75 (t)->RowStride + (i)))
77 #define FETCH(x) fetch_3d_texel_##x
80 #error illegal number of texture dimensions
84 static void FETCH(rgba
)( const struct gl_texture_image
*texImage
,
85 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
87 const GLchan
*src
= CHAN_SRC( texImage
, i
, j
, k
, 4 );
88 GLchan
*rgba
= (GLchan
*) texel
;
89 COPY_CHAN4( rgba
, src
);
92 static void FETCH(rgb
)( const struct gl_texture_image
*texImage
,
93 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
95 const GLchan
*src
= CHAN_SRC( texImage
, i
, j
, k
, 3 );
96 GLchan
*rgba
= (GLchan
*) texel
;
100 rgba
[ACOMP
] = CHAN_MAX
;
103 static void FETCH(alpha
)( const struct gl_texture_image
*texImage
,
104 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
106 const GLchan
*src
= CHAN_SRC( texImage
, i
, j
, k
, 1 );
107 GLchan
*rgba
= (GLchan
*) texel
;
111 rgba
[ACOMP
] = src
[0];
114 static void FETCH(luminance
)( const struct gl_texture_image
*texImage
,
115 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
117 const GLchan
*src
= CHAN_SRC( texImage
, i
, j
, k
, 1 );
118 GLchan
*rgba
= (GLchan
*) texel
;
119 rgba
[RCOMP
] = src
[0];
120 rgba
[GCOMP
] = src
[0];
121 rgba
[BCOMP
] = src
[0];
122 rgba
[ACOMP
] = CHAN_MAX
;
125 static void FETCH(luminance_alpha
)( const struct gl_texture_image
*texImage
,
126 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
128 const GLchan
*src
= CHAN_SRC( texImage
, i
, j
, k
, 2 );
129 GLchan
*rgba
= (GLchan
*) texel
;
130 rgba
[RCOMP
] = src
[0];
131 rgba
[GCOMP
] = src
[0];
132 rgba
[BCOMP
] = src
[0];
133 rgba
[ACOMP
] = src
[1];
136 static void FETCH(intensity
)( const struct gl_texture_image
*texImage
,
137 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
139 const GLchan
*src
= CHAN_SRC( texImage
, i
, j
, k
, 1 );
140 GLchan
*rgba
= (GLchan
*) texel
;
141 rgba
[RCOMP
] = src
[0];
142 rgba
[GCOMP
] = src
[0];
143 rgba
[BCOMP
] = src
[0];
144 rgba
[ACOMP
] = src
[0];
147 static void FETCH(color_index
)( const struct gl_texture_image
*texImage
,
148 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
150 const GLchan
*src
= CHAN_SRC( texImage
, i
, j
, k
, 1 );
151 GLchan
*index
= (GLchan
*) texel
;
155 static void FETCH(depth_component
)( const struct gl_texture_image
*texImage
,
156 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
158 const GLfloat
*src
= FLOAT_SRC( texImage
, i
, j
, k
);
159 GLfloat
*depth
= (GLfloat
*) texel
;
163 static void FETCH(rgba8888
)( const struct gl_texture_image
*texImage
,
164 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
166 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 4 );
167 GLchan
*rgba
= (GLchan
*) texel
;
168 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[3] );
169 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[2] );
170 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[1] );
171 rgba
[ACOMP
] = UBYTE_TO_CHAN( src
[0] );
174 static void FETCH(argb8888
)( const struct gl_texture_image
*texImage
,
175 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
177 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 4 );
178 GLchan
*rgba
= (GLchan
*) texel
;
179 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[2] );
180 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[1] );
181 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[0] );
182 rgba
[ACOMP
] = UBYTE_TO_CHAN( src
[3] );
185 static void FETCH(rgb888
)( const struct gl_texture_image
*texImage
,
186 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
188 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 3 );
189 GLchan
*rgba
= (GLchan
*) texel
;
190 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[2] );
191 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[1] );
192 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[0] );
193 rgba
[ACOMP
] = CHAN_MAX
;
196 static void FETCH(rgb565
)( const struct gl_texture_image
*texImage
,
197 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
199 const GLushort
*src
= USHORT_SRC( texImage
, i
, j
, k
);
200 const GLushort s
= *src
;
201 GLchan
*rgba
= (GLchan
*) texel
;
202 rgba
[RCOMP
] = UBYTE_TO_CHAN( ((s
>> 8) & 0xf8) * 255 / 0xf8 );
203 rgba
[GCOMP
] = UBYTE_TO_CHAN( ((s
>> 3) & 0xfc) * 255 / 0xfc );
204 rgba
[BCOMP
] = UBYTE_TO_CHAN( ((s
<< 3) & 0xf8) * 255 / 0xf8 );
205 rgba
[ACOMP
] = CHAN_MAX
;
208 static void FETCH(argb4444
)( const struct gl_texture_image
*texImage
,
209 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
211 const GLushort
*src
= USHORT_SRC( texImage
, i
, j
, k
);
212 const GLushort s
= *src
;
213 GLchan
*rgba
= (GLchan
*) texel
;
214 rgba
[RCOMP
] = UBYTE_TO_CHAN( ((s
>> 8) & 0xf) * 255 / 0xf );
215 rgba
[GCOMP
] = UBYTE_TO_CHAN( ((s
>> 4) & 0xf) * 255 / 0xf );
216 rgba
[BCOMP
] = UBYTE_TO_CHAN( ((s
) & 0xf) * 255 / 0xf );
217 rgba
[ACOMP
] = UBYTE_TO_CHAN( ((s
>> 12) & 0xf) * 255 / 0xf );
220 static void FETCH(argb1555
)( const struct gl_texture_image
*texImage
,
221 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
223 const GLushort
*src
= USHORT_SRC( texImage
, i
, j
, k
);
224 const GLushort s
= *src
;
225 GLchan
*rgba
= (GLchan
*) texel
;
226 rgba
[RCOMP
] = UBYTE_TO_CHAN( ((s
>> 10) & 0x1f) * 255 / 0x1f );
227 rgba
[GCOMP
] = UBYTE_TO_CHAN( ((s
>> 5) & 0x1f) * 255 / 0x1f );
228 rgba
[BCOMP
] = UBYTE_TO_CHAN( ((s
) & 0x1f) * 255 / 0x1f );
229 rgba
[ACOMP
] = UBYTE_TO_CHAN( ((s
>> 15) & 0x01) * 255 );
232 static void FETCH(al88
)( const struct gl_texture_image
*texImage
,
233 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
235 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 2 );
236 GLchan
*rgba
= (GLchan
*) texel
;
237 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[0] );
238 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[0] );
239 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[0] );
240 rgba
[ACOMP
] = UBYTE_TO_CHAN( src
[1] );
243 static void FETCH(rgb332
)( const struct gl_texture_image
*texImage
,
244 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
246 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 1 );
247 const GLubyte s
= *src
;
248 GLchan
*rgba
= (GLchan
*) texel
;
249 rgba
[RCOMP
] = UBYTE_TO_CHAN( ((s
) & 0xe0) * 255 / 0xe0 );
250 rgba
[GCOMP
] = UBYTE_TO_CHAN( ((s
<< 3) & 0xe0) * 255 / 0xe0 );
251 rgba
[BCOMP
] = UBYTE_TO_CHAN( ((s
<< 5) & 0xc0) * 255 / 0xc0 );
252 rgba
[ACOMP
] = CHAN_MAX
;
255 static void FETCH(a8
)( const struct gl_texture_image
*texImage
,
256 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
258 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 1 );
259 GLchan
*rgba
= (GLchan
*) texel
;
263 rgba
[ACOMP
] = UBYTE_TO_CHAN( src
[0] );
266 static void FETCH(l8
)( const struct gl_texture_image
*texImage
,
267 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
269 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 1 );
270 GLchan
*rgba
= (GLchan
*) texel
;
271 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[0] );
272 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[0] );
273 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[0] );
274 rgba
[ACOMP
] = CHAN_MAX
;
277 static void FETCH(i8
)( const struct gl_texture_image
*texImage
,
278 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
280 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 1 );
281 GLchan
*rgba
= (GLchan
*) texel
;
282 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[0] );
283 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[0] );
284 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[0] );
285 rgba
[ACOMP
] = UBYTE_TO_CHAN( src
[0] );
288 static void FETCH(ci8
)( const struct gl_texture_image
*texImage
,
289 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
291 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 1 );
292 GLchan
*index
= (GLchan
*) texel
;
293 *index
= UBYTE_TO_CHAN( *src
);
296 /* XXX this may break if GLchan != GLubyte */
297 static void FETCH(ycbcr
)( const struct gl_texture_image
*texImage
,
298 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
300 const GLushort
*src0
= USHORT_SRC( texImage
, (i
& ~1), j
, k
); /* even */
301 const GLushort
*src1
= src0
+ 1; /* odd */
302 const GLubyte y0
= (*src0
>> 8) & 0xff; /* luminance */
303 const GLubyte cb
= *src0
& 0xff; /* chroma U */
304 const GLubyte y1
= (*src1
>> 8) & 0xff; /* luminance */
305 const GLubyte cr
= *src1
& 0xff; /* chroma V */
306 GLchan
*rgba
= (GLchan
*) texel
;
309 /* odd pixel: use y1,cr,cb */
310 r
= (GLint
) (1.164 * (y1
-16) + 1.596 * (cr
-128));
311 g
= (GLint
) (1.164 * (y1
-16) - 0.813 * (cr
-128) - 0.391 * (cb
-128));
312 b
= (GLint
) (1.164 * (y1
-16) + 2.018 * (cb
-128));
315 /* even pixel: use y0,cr,cb */
316 r
= (GLint
) (1.164 * (y0
-16) + 1.596 * (cr
-128));
317 g
= (GLint
) (1.164 * (y0
-16) - 0.813 * (cr
-128) - 0.391 * (cb
-128));
318 b
= (GLint
) (1.164 * (y0
-16) + 2.018 * (cb
-128));
320 rgba
[RCOMP
] = CLAMP(r
, 0, CHAN_MAX
);
321 rgba
[GCOMP
] = CLAMP(g
, 0, CHAN_MAX
);
322 rgba
[BCOMP
] = CLAMP(b
, 0, CHAN_MAX
);
323 rgba
[ACOMP
] = CHAN_MAX
;
326 /* XXX this may break if GLchan != GLubyte */
327 static void FETCH(ycbcr_rev
)( const struct gl_texture_image
*texImage
,
328 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
330 const GLushort
*src0
= USHORT_SRC( texImage
, (i
& ~1), j
, k
); /* even */
331 const GLushort
*src1
= src0
+ 1; /* odd */
332 const GLubyte y0
= *src0
& 0xff; /* luminance */
333 const GLubyte cr
= (*src0
>> 8) & 0xff; /* chroma U */
334 const GLubyte y1
= *src1
& 0xff; /* luminance */
335 const GLubyte cb
= (*src1
>> 8) & 0xff; /* chroma V */
336 GLchan
*rgba
= (GLchan
*) texel
;
339 /* odd pixel: use y1,cr,cb */
340 r
= (GLint
) (1.164 * (y1
-16) + 1.596 * (cr
-128));
341 g
= (GLint
) (1.164 * (y1
-16) - 0.813 * (cr
-128) - 0.391 * (cb
-128));
342 b
= (GLint
) (1.164 * (y1
-16) + 2.018 * (cb
-128));
345 /* even pixel: use y0,cr,cb */
346 r
= (GLint
) (1.164 * (y0
-16) + 1.596 * (cr
-128));
347 g
= (GLint
) (1.164 * (y0
-16) - 0.813 * (cr
-128) - 0.391 * (cb
-128));
348 b
= (GLint
) (1.164 * (y0
-16) + 2.018 * (cb
-128));
350 rgba
[RCOMP
] = CLAMP(r
, 0, CHAN_MAX
);
351 rgba
[GCOMP
] = CLAMP(g
, 0, CHAN_MAX
);
352 rgba
[BCOMP
] = CLAMP(b
, 0, CHAN_MAX
);
353 rgba
[ACOMP
] = CHAN_MAX
;
358 static void FETCH(rgb_dxt1
)( const struct gl_texture_image
*texImage
,
359 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
361 /* Extract the (i,j) pixel from texImage->Data and return it
362 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
368 static void FETCH(rgba_dxt1
)( const struct gl_texture_image
*texImage
,
369 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
371 /* Extract the (i,j) pixel from texImage->Data and return it
372 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
378 static void FETCH(rgba_dxt3
)( const struct gl_texture_image
*texImage
,
379 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
381 /* Extract the (i,j) pixel from texImage->Data and return it
382 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
388 static void FETCH(rgba_dxt5
)( const struct gl_texture_image
*texImage
,
389 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
391 /* Extract the (i,j) pixel from texImage->Data and return it
392 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
402 static void FETCH(abgr8888
)( const struct gl_texture_image
*texImage
,
403 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
405 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 4 );
406 GLchan
*rgba
= (GLchan
*) texel
;
407 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[3] );
408 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[2] );
409 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[1] );
410 rgba
[ACOMP
] = UBYTE_TO_CHAN( src
[0] );
413 static void FETCH(bgra8888
)( const struct gl_texture_image
*texImage
,
414 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
416 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 4 );
417 GLchan
*rgba
= (GLchan
*) texel
;
418 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[2] );
419 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[1] );
420 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[0] );
421 rgba
[ACOMP
] = UBYTE_TO_CHAN( src
[3] );
424 static void FETCH(bgr888
)( const struct gl_texture_image
*texImage
,
425 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
427 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 3 );
428 GLchan
*rgba
= (GLchan
*) texel
;
429 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[2] );
430 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[1] );
431 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[0] );
432 rgba
[ACOMP
] = CHAN_MAX
;
435 static void FETCH(bgr565
)( const struct gl_texture_image
*texImage
,
436 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
438 const GLushort
*src
= USHORT_SRC( texImage
, i
, j
, k
);
439 const GLushort s
= *src
;
440 GLchan
*rgba
= (GLchan
*) texel
;
441 rgba
[RCOMP
] = UBYTE_TO_CHAN( ((s
>> 8) & 0xf8) * 255 / 0xf8 );
442 rgba
[GCOMP
] = UBYTE_TO_CHAN( ((s
>> 3) & 0xfc) * 255 / 0xfc );
443 rgba
[BCOMP
] = UBYTE_TO_CHAN( ((s
<< 3) & 0xf8) * 255 / 0xf8 );
444 rgba
[ACOMP
] = CHAN_MAX
;
447 static void FETCH(bgra4444
)( const struct gl_texture_image
*texImage
,
448 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
450 const GLushort
*src
= USHORT_SRC( texImage
, i
, j
, k
);
451 const GLushort s
= *src
;
452 GLchan
*rgba
= (GLchan
*) texel
;
453 rgba
[RCOMP
] = UBYTE_TO_CHAN( ((s
>> 8) & 0xf) * 255 / 0xf );
454 rgba
[GCOMP
] = UBYTE_TO_CHAN( ((s
>> 4) & 0xf) * 255 / 0xf );
455 rgba
[BCOMP
] = UBYTE_TO_CHAN( ((s
) & 0xf) * 255 / 0xf );
456 rgba
[ACOMP
] = UBYTE_TO_CHAN( ((s
>> 12) & 0xf) * 255 / 0xf );
459 static void FETCH(bgra5551
)( const struct gl_texture_image
*texImage
,
460 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
462 const GLushort
*src
= USHORT_SRC( texImage
, i
, j
, k
);
463 const GLushort s
= *src
;
464 GLchan
*rgba
= (GLchan
*) texel
;
465 rgba
[RCOMP
] = UBYTE_TO_CHAN( ((s
>> 10) & 0x1f) * 255 / 0x1f );
466 rgba
[GCOMP
] = UBYTE_TO_CHAN( ((s
>> 5) & 0x1f) * 255 / 0x1f );
467 rgba
[BCOMP
] = UBYTE_TO_CHAN( ((s
) & 0x1f) * 255 / 0x1f );
468 rgba
[ACOMP
] = UBYTE_TO_CHAN( ((s
>> 15) & 0x01) * 255 );
471 static void FETCH(la88
)( const struct gl_texture_image
*texImage
,
472 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
474 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 2 );
475 GLchan
*rgba
= (GLchan
*) texel
;
476 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[0] );
477 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[0] );
478 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[0] );
479 rgba
[ACOMP
] = UBYTE_TO_CHAN( src
[1] );
482 static void FETCH(bgr233
)( const struct gl_texture_image
*texImage
,
483 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
485 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 1 );
486 const GLubyte s
= *src
;
487 GLchan
*rgba
= (GLchan
*) texel
;
488 rgba
[RCOMP
] = UBYTE_TO_CHAN( ((s
) & 0xe0) * 255 / 0xe0 );
489 rgba
[GCOMP
] = UBYTE_TO_CHAN( ((s
<< 3) & 0xe0) * 255 / 0xe0 );
490 rgba
[BCOMP
] = UBYTE_TO_CHAN( ((s
<< 5) & 0xc0) * 255 / 0xc0 );
491 rgba
[ACOMP
] = CHAN_MAX
;