83715d3fdb3f5410b9c09675cd6dedc4d0b50aa5
[mesa.git] / src / mesa / main / texformat_tmp.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 5.1
4 *
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 *
24 * Authors:
25 * Gareth Hughes
26 * Brian Paul
27 */
28
29
30 /*
31 * This template file generates texel fetch functions for 1-D, 2-D and 3-D
32 * texture images.
33 */
34
35
36 #if DIM == 1
37
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))
46
47 #define FETCH(x) fetch_1d_texel_##x
48
49 #elif DIM == 2
50
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)))
59
60 #define FETCH(x) fetch_2d_texel_##x
61
62 #elif DIM == 3
63
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)))
76
77 #define FETCH(x) fetch_3d_texel_##x
78
79 #else
80 #error illegal number of texture dimensions
81 #endif
82
83
84 static void FETCH(rgba)( const struct gl_texture_image *texImage,
85 GLint i, GLint j, GLint k, GLvoid *texel )
86 {
87 const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 );
88 GLchan *rgba = (GLchan *) texel;
89 COPY_CHAN4( rgba, src );
90 }
91
92 static void FETCH(rgb)( const struct gl_texture_image *texImage,
93 GLint i, GLint j, GLint k, GLvoid *texel )
94 {
95 const GLchan *src = CHAN_SRC( texImage, i, j, k, 3 );
96 GLchan *rgba = (GLchan *) texel;
97 rgba[RCOMP] = src[0];
98 rgba[GCOMP] = src[1];
99 rgba[BCOMP] = src[2];
100 rgba[ACOMP] = CHAN_MAX;
101 }
102
103 static void FETCH(alpha)( const struct gl_texture_image *texImage,
104 GLint i, GLint j, GLint k, GLvoid *texel )
105 {
106 const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
107 GLchan *rgba = (GLchan *) texel;
108 rgba[RCOMP] = 0;
109 rgba[GCOMP] = 0;
110 rgba[BCOMP] = 0;
111 rgba[ACOMP] = src[0];
112 }
113
114 static void FETCH(luminance)( const struct gl_texture_image *texImage,
115 GLint i, GLint j, GLint k, GLvoid *texel )
116 {
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;
123 }
124
125 static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage,
126 GLint i, GLint j, GLint k, GLvoid *texel )
127 {
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];
134 }
135
136 static void FETCH(intensity)( const struct gl_texture_image *texImage,
137 GLint i, GLint j, GLint k, GLvoid *texel )
138 {
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];
145 }
146
147 static void FETCH(color_index)( const struct gl_texture_image *texImage,
148 GLint i, GLint j, GLint k, GLvoid *texel )
149 {
150 const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
151 GLchan *index = (GLchan *) texel;
152 *index = *src;
153 }
154
155 static void FETCH(depth_component)( const struct gl_texture_image *texImage,
156 GLint i, GLint j, GLint k, GLvoid *texel )
157 {
158 const GLfloat *src = FLOAT_SRC( texImage, i, j, k );
159 GLfloat *depth = (GLfloat *) texel;
160 *depth = *src;
161 }
162
163 static void FETCH(rgba8888)( const struct gl_texture_image *texImage,
164 GLint i, GLint j, GLint k, GLvoid *texel )
165 {
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] );
172 }
173
174 static void FETCH(argb8888)( const struct gl_texture_image *texImage,
175 GLint i, GLint j, GLint k, GLvoid *texel )
176 {
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] );
183 }
184
185 static void FETCH(rgb888)( const struct gl_texture_image *texImage,
186 GLint i, GLint j, GLint k, GLvoid *texel )
187 {
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;
194 }
195
196 static void FETCH(rgb565)( const struct gl_texture_image *texImage,
197 GLint i, GLint j, GLint k, GLvoid *texel )
198 {
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;
206 }
207
208 static void FETCH(argb4444)( const struct gl_texture_image *texImage,
209 GLint i, GLint j, GLint k, GLvoid *texel )
210 {
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 );
218 }
219
220 static void FETCH(argb1555)( const struct gl_texture_image *texImage,
221 GLint i, GLint j, GLint k, GLvoid *texel )
222 {
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 );
230 }
231
232 static void FETCH(al88)( const struct gl_texture_image *texImage,
233 GLint i, GLint j, GLint k, GLvoid *texel )
234 {
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] );
241 }
242
243 static void FETCH(rgb332)( const struct gl_texture_image *texImage,
244 GLint i, GLint j, GLint k, GLvoid *texel )
245 {
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;
253 }
254
255 static void FETCH(a8)( const struct gl_texture_image *texImage,
256 GLint i, GLint j, GLint k, GLvoid *texel )
257 {
258 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
259 GLchan *rgba = (GLchan *) texel;
260 rgba[RCOMP] = 0;
261 rgba[GCOMP] = 0;
262 rgba[BCOMP] = 0;
263 rgba[ACOMP] = UBYTE_TO_CHAN( src[0] );
264 }
265
266 static void FETCH(l8)( const struct gl_texture_image *texImage,
267 GLint i, GLint j, GLint k, GLvoid *texel )
268 {
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;
275 }
276
277 static void FETCH(i8)( const struct gl_texture_image *texImage,
278 GLint i, GLint j, GLint k, GLvoid *texel )
279 {
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] );
286 }
287
288 static void FETCH(ci8)( const struct gl_texture_image *texImage,
289 GLint i, GLint j, GLint k, GLvoid *texel )
290 {
291 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
292 GLchan *index = (GLchan *) texel;
293 *index = UBYTE_TO_CHAN( *src );
294 }
295
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 )
299 {
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;
307 GLint r, g, b;
308 if (i & 1) {
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));
313 }
314 else {
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));
319 }
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;
324 }
325
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 )
329 {
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;
337 GLint r, g, b;
338 if (i & 1) {
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));
343 }
344 else {
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));
349 }
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;
354 }
355
356
357 #if DIM == 2
358 static void FETCH(rgb_dxt1)( const struct gl_texture_image *texImage,
359 GLint i, GLint j, GLint k, GLvoid *texel )
360 {
361 /* Extract the (i,j) pixel from texImage->Data and return it
362 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
363 */
364 }
365 #endif
366
367 #if DIM == 2
368 static void FETCH(rgba_dxt1)( const struct gl_texture_image *texImage,
369 GLint i, GLint j, GLint k, GLvoid *texel )
370 {
371 /* Extract the (i,j) pixel from texImage->Data and return it
372 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
373 */
374 }
375 #endif
376
377 #if DIM == 2
378 static void FETCH(rgba_dxt3)( const struct gl_texture_image *texImage,
379 GLint i, GLint j, GLint k, GLvoid *texel )
380 {
381 /* Extract the (i,j) pixel from texImage->Data and return it
382 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
383 */
384 }
385 #endif
386
387 #if DIM == 2
388 static void FETCH(rgba_dxt5)( const struct gl_texture_image *texImage,
389 GLint i, GLint j, GLint k, GLvoid *texel )
390 {
391 /* Extract the (i,j) pixel from texImage->Data and return it
392 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
393 */
394 }
395 #endif
396
397
398
399 /* big-endian */
400
401 #if 0
402 static void FETCH(abgr8888)( const struct gl_texture_image *texImage,
403 GLint i, GLint j, GLint k, GLvoid *texel )
404 {
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] );
411 }
412
413 static void FETCH(bgra8888)( const struct gl_texture_image *texImage,
414 GLint i, GLint j, GLint k, GLvoid *texel )
415 {
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] );
422 }
423
424 static void FETCH(bgr888)( const struct gl_texture_image *texImage,
425 GLint i, GLint j, GLint k, GLvoid *texel )
426 {
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;
433 }
434
435 static void FETCH(bgr565)( const struct gl_texture_image *texImage,
436 GLint i, GLint j, GLint k, GLvoid *texel )
437 {
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;
445 }
446
447 static void FETCH(bgra4444)( const struct gl_texture_image *texImage,
448 GLint i, GLint j, GLint k, GLvoid *texel )
449 {
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 );
457 }
458
459 static void FETCH(bgra5551)( const struct gl_texture_image *texImage,
460 GLint i, GLint j, GLint k, GLvoid *texel )
461 {
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 );
469 }
470
471 static void FETCH(la88)( const struct gl_texture_image *texImage,
472 GLint i, GLint j, GLint k, GLvoid *texel )
473 {
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] );
480 }
481
482 static void FETCH(bgr233)( const struct gl_texture_image *texImage,
483 GLint i, GLint j, GLint k, GLvoid *texel )
484 {
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;
492 }
493 #endif
494
495
496 #undef CHAN_SRC
497 #undef UBYTE_SRC
498 #undef USHORT_SRC
499 #undef FLOAT_SRC
500 #undef FETCH
501 #undef DIM