1 /* $Id: s_readpix.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
38 #include "s_alphabuf.h"
41 #include "s_stencil.h"
46 * Read a block of color index pixels.
48 static void read_index_pixels( GLcontext
*ctx
,
50 GLsizei width
, GLsizei height
,
51 GLenum type
, GLvoid
*pixels
,
52 const struct gl_pixelstore_attrib
*packing
)
54 GLint i
, j
, readWidth
;
57 if (ctx
->Visual
.RGBAflag
) {
58 gl_error( ctx
, GL_INVALID_OPERATION
, "glReadPixels" );
62 ASSERT(ctx
->Driver
.SetReadBuffer
);
63 (*ctx
->Driver
.SetReadBuffer
)(ctx
, ctx
->ReadBuffer
, ctx
->Pixel
.DriverReadBuffer
);
65 readWidth
= (width
> MAX_WIDTH
) ? MAX_WIDTH
: width
;
67 /* process image row by row */
68 for (j
=0;j
<height
;j
++,y
++) {
69 GLuint index
[MAX_WIDTH
];
72 (*ctx
->Driver
.ReadCI32Span
)( ctx
, readWidth
, x
, y
, index
);
74 if (ctx
->Pixel
.IndexShift
!=0 || ctx
->Pixel
.IndexOffset
!=0) {
75 _mesa_shift_and_offset_ci( ctx
, readWidth
, index
);
78 if (ctx
->Pixel
.MapColorFlag
) {
79 _mesa_map_ci(ctx
, readWidth
, index
);
82 dest
= _mesa_image_address(packing
, pixels
,
83 width
, height
, GL_COLOR_INDEX
, type
, 0, j
, 0);
86 case GL_UNSIGNED_BYTE
:
88 GLubyte
*dst
= (GLubyte
*) dest
;
89 for (i
=0;i
<readWidth
;i
++) {
90 *dst
++ = (GLubyte
) index
[i
];
96 GLbyte
*dst
= (GLbyte
*) dest
;
97 for (i
=0;i
<readWidth
;i
++) {
98 dst
[i
] = (GLbyte
) index
[i
];
102 case GL_UNSIGNED_SHORT
:
104 GLushort
*dst
= (GLushort
*) dest
;
105 for (i
=0;i
<readWidth
;i
++) {
106 dst
[i
] = (GLushort
) index
[i
];
108 if (packing
->SwapBytes
) {
109 _mesa_swap2( (GLushort
*) dst
, readWidth
);
115 GLshort
*dst
= (GLshort
*) dest
;
116 for (i
=0;i
<readWidth
;i
++) {
117 dst
[i
] = (GLshort
) index
[i
];
119 if (packing
->SwapBytes
) {
120 _mesa_swap2( (GLushort
*) dst
, readWidth
);
124 case GL_UNSIGNED_INT
:
126 GLuint
*dst
= (GLuint
*) dest
;
127 for (i
=0;i
<readWidth
;i
++) {
128 dst
[i
] = (GLuint
) index
[i
];
130 if (packing
->SwapBytes
) {
131 _mesa_swap4( (GLuint
*) dst
, readWidth
);
137 GLint
*dst
= (GLint
*) dest
;
138 for (i
=0;i
<readWidth
;i
++) {
139 dst
[i
] = (GLint
) index
[i
];
141 if (packing
->SwapBytes
) {
142 _mesa_swap4( (GLuint
*) dst
, readWidth
);
148 GLfloat
*dst
= (GLfloat
*) dest
;
149 for (i
=0;i
<readWidth
;i
++) {
150 dst
[i
] = (GLfloat
) index
[i
];
152 if (packing
->SwapBytes
) {
153 _mesa_swap4( (GLuint
*) dst
, readWidth
);
158 gl_error( ctx
, GL_INVALID_ENUM
, "glReadPixels(type)" );
159 j
= height
+ 1; /* exit loop */
163 (*ctx
->Driver
.SetReadBuffer
)(ctx
, ctx
->DrawBuffer
, ctx
->Color
.DriverDrawBuffer
);
168 static void read_depth_pixels( GLcontext
*ctx
,
170 GLsizei width
, GLsizei height
,
171 GLenum type
, GLvoid
*pixels
,
172 const struct gl_pixelstore_attrib
*packing
)
174 GLint i
, j
, readWidth
;
175 GLboolean bias_or_scale
;
178 if (ctx
->Visual
.DepthBits
<= 0) {
179 /* No depth buffer */
180 gl_error( ctx
, GL_INVALID_OPERATION
, "glReadPixels" );
184 readWidth
= (width
> MAX_WIDTH
) ? MAX_WIDTH
: width
;
186 if (type
!= GL_BYTE
&&
187 type
!= GL_UNSIGNED_BYTE
&&
189 type
!= GL_UNSIGNED_SHORT
&&
191 type
!= GL_UNSIGNED_INT
&&
193 gl_error( ctx
, GL_INVALID_OPERATION
, "glReadPixels(depth type)");
197 bias_or_scale
= ctx
->Pixel
.DepthBias
!=0.0 || ctx
->Pixel
.DepthScale
!=1.0;
199 if (type
==GL_UNSIGNED_SHORT
&& ctx
->Visual
.DepthBits
== 16
200 && !bias_or_scale
&& !packing
->SwapBytes
) {
201 /* Special case: directly read 16-bit unsigned depth values. */
202 for (j
=0;j
<height
;j
++,y
++) {
203 GLdepth depth
[MAX_WIDTH
];
204 GLushort
*dst
= (GLushort
*) _mesa_image_address( packing
, pixels
,
205 width
, height
, GL_DEPTH_COMPONENT
, type
, 0, j
, 0 );
207 _mesa_read_depth_span(ctx
, width
, x
, y
, depth
);
208 for (i
= 0; i
< width
; i
++)
212 else if (type
==GL_UNSIGNED_INT
&& ctx
->Visual
.DepthBits
== 32
213 && !bias_or_scale
&& !packing
->SwapBytes
) {
214 /* Special case: directly read 32-bit unsigned depth values. */
215 for (j
=0;j
<height
;j
++,y
++) {
216 GLdepth
*dst
= (GLdepth
*) _mesa_image_address( packing
, pixels
,
217 width
, height
, GL_DEPTH_COMPONENT
, type
, 0, j
, 0 );
218 _mesa_read_depth_span(ctx
, width
, x
, y
, dst
);
222 /* General case (slower) */
223 for (j
=0;j
<height
;j
++,y
++) {
224 GLfloat depth
[MAX_WIDTH
];
227 _mesa_read_depth_span_float(ctx
, readWidth
, x
, y
, depth
);
230 for (i
=0;i
<readWidth
;i
++) {
232 d
= depth
[i
] * ctx
->Pixel
.DepthScale
+ ctx
->Pixel
.DepthBias
;
233 depth
[i
] = CLAMP( d
, 0.0F
, 1.0F
);
237 dest
= _mesa_image_address(packing
, pixels
,
238 width
, height
, GL_DEPTH_COMPONENT
, type
, 0, j
, 0);
241 case GL_UNSIGNED_BYTE
:
243 GLubyte
*dst
= (GLubyte
*) dest
;
244 for (i
=0;i
<readWidth
;i
++) {
245 dst
[i
] = FLOAT_TO_UBYTE( depth
[i
] );
251 GLbyte
*dst
= (GLbyte
*) dest
;
252 for (i
=0;i
<readWidth
;i
++) {
253 dst
[i
] = FLOAT_TO_BYTE( depth
[i
] );
257 case GL_UNSIGNED_SHORT
:
259 GLushort
*dst
= (GLushort
*) dest
;
260 for (i
=0;i
<readWidth
;i
++) {
261 dst
[i
] = FLOAT_TO_USHORT( depth
[i
] );
263 if (packing
->SwapBytes
) {
264 _mesa_swap2( (GLushort
*) dst
, readWidth
);
270 GLshort
*dst
= (GLshort
*) dest
;
271 for (i
=0;i
<readWidth
;i
++) {
272 dst
[i
] = FLOAT_TO_SHORT( depth
[i
] );
274 if (packing
->SwapBytes
) {
275 _mesa_swap2( (GLushort
*) dst
, readWidth
);
279 case GL_UNSIGNED_INT
:
281 GLuint
*dst
= (GLuint
*) dest
;
282 for (i
=0;i
<readWidth
;i
++) {
283 dst
[i
] = FLOAT_TO_UINT( depth
[i
] );
285 if (packing
->SwapBytes
) {
286 _mesa_swap4( (GLuint
*) dst
, readWidth
);
292 GLint
*dst
= (GLint
*) dest
;
293 for (i
=0;i
<readWidth
;i
++) {
294 dst
[i
] = FLOAT_TO_INT( depth
[i
] );
296 if (packing
->SwapBytes
) {
297 _mesa_swap4( (GLuint
*) dst
, readWidth
);
303 GLfloat
*dst
= (GLfloat
*) dest
;
304 for (i
=0;i
<readWidth
;i
++) {
307 if (packing
->SwapBytes
) {
308 _mesa_swap4( (GLuint
*) dst
, readWidth
);
313 gl_error( ctx
, GL_INVALID_ENUM
, "glReadPixels(type)" );
321 static void read_stencil_pixels( GLcontext
*ctx
,
323 GLsizei width
, GLsizei height
,
324 GLenum type
, GLvoid
*pixels
,
325 const struct gl_pixelstore_attrib
*packing
)
327 GLboolean shift_or_offset
;
328 GLint i
, j
, readWidth
;
330 if (type
!= GL_BYTE
&&
331 type
!= GL_UNSIGNED_BYTE
&&
333 type
!= GL_UNSIGNED_SHORT
&&
335 type
!= GL_UNSIGNED_INT
&&
338 gl_error( ctx
, GL_INVALID_OPERATION
, "glReadPixels(stencil type)");
342 readWidth
= (width
> MAX_WIDTH
) ? MAX_WIDTH
: width
;
344 if (ctx
->Visual
.StencilBits
<=0) {
345 /* No stencil buffer */
346 gl_error( ctx
, GL_INVALID_OPERATION
, "glReadPixels" );
350 shift_or_offset
= ctx
->Pixel
.IndexShift
!=0 || ctx
->Pixel
.IndexOffset
!=0;
352 /* process image row by row */
353 for (j
=0;j
<height
;j
++,y
++) {
355 GLstencil stencil
[MAX_WIDTH
];
357 _mesa_read_stencil_span( ctx
, readWidth
, x
, y
, stencil
);
359 if (shift_or_offset
) {
360 _mesa_shift_and_offset_stencil( ctx
, readWidth
, stencil
);
363 if (ctx
->Pixel
.MapStencilFlag
) {
364 _mesa_map_stencil( ctx
, readWidth
, stencil
);
367 dest
= _mesa_image_address( packing
, pixels
,
368 width
, height
, GL_STENCIL_INDEX
, type
, 0, j
, 0 );
371 case GL_UNSIGNED_BYTE
:
372 if (sizeof(GLstencil
) == 8) {
373 MEMCPY( dest
, stencil
, readWidth
);
376 GLubyte
*dst
= (GLubyte
*) dest
;
377 for (i
=0;i
<readWidth
;i
++) {
378 dst
[i
] = (GLubyte
) stencil
[i
];
383 if (sizeof(GLstencil
) == 8) {
384 MEMCPY( dest
, stencil
, readWidth
);
387 GLbyte
*dst
= (GLbyte
*) dest
;
388 for (i
=0;i
<readWidth
;i
++) {
389 dst
[i
] = (GLbyte
) stencil
[i
];
393 case GL_UNSIGNED_SHORT
:
395 GLushort
*dst
= (GLushort
*) dest
;
396 for (i
=0;i
<readWidth
;i
++) {
397 dst
[i
] = (GLushort
) stencil
[i
];
399 if (packing
->SwapBytes
) {
400 _mesa_swap2( (GLushort
*) dst
, readWidth
);
406 GLshort
*dst
= (GLshort
*) dest
;
407 for (i
=0;i
<readWidth
;i
++) {
408 dst
[i
] = (GLshort
) stencil
[i
];
410 if (packing
->SwapBytes
) {
411 _mesa_swap2( (GLushort
*) dst
, readWidth
);
415 case GL_UNSIGNED_INT
:
417 GLuint
*dst
= (GLuint
*) dest
;
418 for (i
=0;i
<readWidth
;i
++) {
419 dst
[i
] = (GLuint
) stencil
[i
];
421 if (packing
->SwapBytes
) {
422 _mesa_swap4( (GLuint
*) dst
, readWidth
);
428 GLint
*dst
= (GLint
*) dest
;
429 for (i
=0;i
<readWidth
;i
++) {
430 *dst
++ = (GLint
) stencil
[i
];
432 if (packing
->SwapBytes
) {
433 _mesa_swap4( (GLuint
*) dst
, readWidth
);
439 GLfloat
*dst
= (GLfloat
*) dest
;
440 for (i
=0;i
<readWidth
;i
++) {
441 dst
[i
] = (GLfloat
) stencil
[i
];
443 if (packing
->SwapBytes
) {
444 _mesa_swap4( (GLuint
*) dst
, readWidth
);
449 if (packing
->LsbFirst
) {
450 GLubyte
*dst
= (GLubyte
*) dest
;
452 for (i
= 0; i
< readWidth
; i
++) {
455 *dst
|= ((stencil
!= 0) << shift
);
464 GLubyte
*dst
= (GLubyte
*) dest
;
466 for (i
= 0; i
< readWidth
; i
++) {
469 *dst
|= ((stencil
!= 0) << shift
);
479 gl_error( ctx
, GL_INVALID_ENUM
, "glReadPixels(type)" );
487 * Optimized glReadPixels for particular pixel formats:
488 * GL_UNSIGNED_BYTE, GL_RGBA
489 * when pixel scaling, biasing and mapping are disabled.
492 read_fast_rgba_pixels( GLcontext
*ctx
,
494 GLsizei width
, GLsizei height
,
495 GLenum format
, GLenum type
,
497 const struct gl_pixelstore_attrib
*packing
)
499 /* can't do scale, bias, mapping, etc */
500 if (ctx
->ImageTransferState
)
503 /* can't do fancy pixel packing */
504 if (packing
->Alignment
!= 1 || packing
->SwapBytes
|| packing
->LsbFirst
)
510 GLint readWidth
= width
; /* actual width read */
511 GLint readHeight
= height
; /* actual height read */
512 GLint skipPixels
= packing
->SkipPixels
;
513 GLint skipRows
= packing
->SkipRows
;
516 if (packing
->RowLength
> 0)
517 rowLength
= packing
->RowLength
;
521 /* horizontal clipping */
522 if (srcX
< ctx
->ReadBuffer
->Xmin
) {
523 skipPixels
+= (ctx
->ReadBuffer
->Xmin
- srcX
);
524 readWidth
-= (ctx
->ReadBuffer
->Xmin
- srcX
);
525 srcX
= ctx
->ReadBuffer
->Xmin
;
527 if (srcX
+ readWidth
> ctx
->ReadBuffer
->Xmax
)
528 readWidth
-= (srcX
+ readWidth
- ctx
->ReadBuffer
->Xmax
);
532 /* vertical clipping */
533 if (srcY
< ctx
->ReadBuffer
->Ymin
) {
534 skipRows
+= (ctx
->ReadBuffer
->Ymin
- srcY
);
535 readHeight
-= (ctx
->ReadBuffer
->Ymin
- srcY
);
536 srcY
= ctx
->ReadBuffer
->Ymin
;
538 if (srcY
+ readHeight
> ctx
->ReadBuffer
->Ymax
)
539 readHeight
-= (srcY
+ readHeight
- ctx
->ReadBuffer
->Ymax
);
545 * The window region at (destX, destY) of size (readWidth, readHeight)
547 * We'll write pixel data to buffer pointed to by "pixels" but we'll
548 * skip "skipRows" rows and skip "skipPixels" pixels/row.
551 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_BYTE
) {
552 #elif CHAN_BITS == 16
553 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT
) {
557 GLchan
*dest
= (GLchan
*) pixels
558 + (skipRows
* rowLength
+ skipPixels
) * 4;
560 for (row
=0; row
<readHeight
; row
++) {
561 (*ctx
->Driver
.ReadRGBASpan
)(ctx
, readWidth
, srcX
, srcY
,
562 (GLchan (*)[4]) dest
);
563 if (ctx
->DrawBuffer
->UseSoftwareAlphaBuffers
) {
564 _mesa_read_alpha_span(ctx
, readWidth
, srcX
, srcY
,
565 (GLchan (*)[4]) dest
);
567 dest
+= rowLength
* 4;
573 /* can't do this format/type combination */
582 * Read R, G, B, A, RGB, L, or LA pixels.
584 static void read_rgba_pixels( GLcontext
*ctx
,
586 GLsizei width
, GLsizei height
,
587 GLenum format
, GLenum type
, GLvoid
*pixels
,
588 const struct gl_pixelstore_attrib
*packing
)
592 (*ctx
->Driver
.SetReadBuffer
)(ctx
, ctx
->ReadBuffer
, ctx
->Pixel
.DriverReadBuffer
);
594 /* Try optimized path first */
595 if (read_fast_rgba_pixels( ctx
, x
, y
, width
, height
,
596 format
, type
, pixels
, packing
)) {
598 (*ctx
->Driver
.SetReadBuffer
)(ctx
, ctx
->DrawBuffer
, ctx
->Color
.DriverDrawBuffer
);
602 readWidth
= (width
> MAX_WIDTH
) ? MAX_WIDTH
: width
;
604 /* do error checking on pixel type, format was already checked by caller */
606 case GL_UNSIGNED_BYTE
:
608 case GL_UNSIGNED_SHORT
:
610 case GL_UNSIGNED_INT
:
613 case GL_UNSIGNED_BYTE_3_3_2
:
614 case GL_UNSIGNED_BYTE_2_3_3_REV
:
615 case GL_UNSIGNED_SHORT_5_6_5
:
616 case GL_UNSIGNED_SHORT_5_6_5_REV
:
617 case GL_UNSIGNED_SHORT_4_4_4_4
:
618 case GL_UNSIGNED_SHORT_4_4_4_4_REV
:
619 case GL_UNSIGNED_SHORT_5_5_5_1
:
620 case GL_UNSIGNED_SHORT_1_5_5_5_REV
:
621 case GL_UNSIGNED_INT_8_8_8_8
:
622 case GL_UNSIGNED_INT_8_8_8_8_REV
:
623 case GL_UNSIGNED_INT_10_10_10_2
:
624 case GL_UNSIGNED_INT_2_10_10_10_REV
:
625 /* valid pixel type */
628 gl_error( ctx
, GL_INVALID_ENUM
, "glReadPixels(type)" );
632 if (!_mesa_is_legal_format_and_type(format
, type
) ||
633 format
== GL_INTENSITY
) {
634 gl_error(ctx
, GL_INVALID_OPERATION
, "glReadPixels(format or type)");
638 if (ctx
->Pixel
.Convolution2DEnabled
|| ctx
->Pixel
.Separable2DEnabled
) {
639 const GLuint transferOps
= ctx
->ImageTransferState
;
640 GLfloat
*dest
, *src
, *tmpImage
, *convImage
;
643 tmpImage
= (GLfloat
*) MALLOC(width
* height
* 4 * sizeof(GLfloat
));
645 gl_error(ctx
, GL_OUT_OF_MEMORY
, "glReadPixels");
648 convImage
= (GLfloat
*) MALLOC(width
* height
* 4 * sizeof(GLfloat
));
651 gl_error(ctx
, GL_OUT_OF_MEMORY
, "glReadPixels");
655 /* read full RGBA, FLOAT image */
657 for (row
= 0; row
< height
; row
++, y
++) {
658 GLchan rgba
[MAX_WIDTH
][4];
659 if (ctx
->Visual
.RGBAflag
) {
660 gl_read_rgba_span(ctx
, ctx
->ReadBuffer
, readWidth
, x
, y
, rgba
);
663 GLuint index
[MAX_WIDTH
];
664 (*ctx
->Driver
.ReadCI32Span
)(ctx
, readWidth
, x
, y
, index
);
665 if (ctx
->Pixel
.IndexShift
!= 0 || ctx
->Pixel
.IndexOffset
!=0 ) {
666 _mesa_map_ci(ctx
, readWidth
, index
);
668 _mesa_map_ci_to_rgba_chan(ctx
, readWidth
, index
, rgba
);
670 _mesa_pack_rgba_span(ctx
, readWidth
, (const GLchan (*)[4]) rgba
,
671 GL_RGBA
, GL_FLOAT
, dest
, &_mesa_native_packing
,
672 transferOps
& IMAGE_PRE_CONVOLUTION_BITS
);
677 if (ctx
->Pixel
.Convolution2DEnabled
) {
678 _mesa_convolve_2d_image(ctx
, &readWidth
, &height
, tmpImage
, convImage
);
681 ASSERT(ctx
->Pixel
.Separable2DEnabled
);
682 _mesa_convolve_sep_image(ctx
, &readWidth
, &height
, tmpImage
, convImage
);
686 /* finish transfer ops and pack the resulting image */
688 for (row
= 0; row
< height
; row
++) {
690 dest
= _mesa_image_address(packing
, pixels
, width
, height
,
691 format
, type
, 0, row
, 0);
692 _mesa_pack_float_rgba_span(ctx
, readWidth
,
693 (const GLfloat (*)[4]) src
,
694 format
, type
, dest
, packing
,
695 transferOps
& IMAGE_POST_CONVOLUTION_BITS
);
696 src
+= readWidth
* 4;
702 for (row
= 0; row
< height
; row
++, y
++) {
703 GLchan rgba
[MAX_WIDTH
][4];
705 if (ctx
->Visual
.RGBAflag
) {
706 gl_read_rgba_span(ctx
, ctx
->ReadBuffer
, readWidth
, x
, y
, rgba
);
709 GLuint index
[MAX_WIDTH
];
710 (*ctx
->Driver
.ReadCI32Span
)(ctx
, readWidth
, x
, y
, index
);
711 if (ctx
->Pixel
.IndexShift
!= 0 || ctx
->Pixel
.IndexOffset
!= 0) {
712 _mesa_map_ci(ctx
, readWidth
, index
);
714 _mesa_map_ci_to_rgba_chan(ctx
, readWidth
, index
, rgba
);
716 dst
= _mesa_image_address(packing
, pixels
, width
, height
,
717 format
, type
, 0, row
, 0);
718 _mesa_pack_rgba_span(ctx
, readWidth
, (const GLchan (*)[4]) rgba
,
719 format
, type
, dst
, packing
,
720 ctx
->ImageTransferState
);
724 (*ctx
->Driver
.SetReadBuffer
)(ctx
, ctx
->DrawBuffer
, ctx
->Color
.DriverDrawBuffer
);
730 _swrast_ReadPixels( GLcontext
*ctx
,
731 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
732 GLenum format
, GLenum type
,
733 const struct gl_pixelstore_attrib
*pack
,
740 read_index_pixels(ctx
, x
, y
, width
, height
, type
, pixels
, &ctx
->Pack
);
742 case GL_STENCIL_INDEX
:
743 read_stencil_pixels(ctx
, x
,y
, width
,height
, type
, pixels
, &ctx
->Pack
);
745 case GL_DEPTH_COMPONENT
:
746 read_depth_pixels(ctx
, x
, y
, width
, height
, type
, pixels
, &ctx
->Pack
);
754 case GL_LUMINANCE_ALPHA
:
759 read_rgba_pixels(ctx
, x
, y
, width
, height
,
760 format
, type
, pixels
, &ctx
->Pack
);
763 gl_error( ctx
, GL_INVALID_ENUM
, "glReadPixels(format)" );