1 /* $Id: drawpix.c,v 1.20 2000/04/12 18:54:48 brianp 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.
52 * Given the dest position, size and skipPixels and skipRows values
53 * for a glDrawPixels command, perform clipping of the image bounds
54 * so the result lies withing the context's buffer bounds.
55 * Return: GL_TRUE if image is ready for drawing
56 * GL_FALSE if image was completely clipped away (draw nothing)
59 _mesa_clip_pixelrect(const GLcontext
*ctx
,
60 GLint
*destX
, GLint
*destY
,
61 GLsizei
*width
, GLsizei
*height
,
62 GLint
*skipPixels
, GLint
*skipRows
)
64 const GLframebuffer
*buffer
= ctx
->DrawBuffer
;
67 if (*destX
< buffer
->Xmin
) {
68 *skipPixels
+= (buffer
->Xmin
- *destX
);
69 *width
-= (buffer
->Xmin
- *destX
);
70 *destX
= buffer
->Xmin
;
73 if (*destX
+ *width
> buffer
->Xmax
)
74 *width
-= (*destX
+ *width
- buffer
->Xmax
- 1);
80 if (*destY
< buffer
->Ymin
) {
81 *skipRows
+= (buffer
->Ymin
- *destY
);
82 *height
-= (buffer
->Ymin
- *destY
);
83 *destY
= buffer
->Ymin
;
86 if (*destY
+ *height
> buffer
->Ymax
)
87 *height
-= (*destY
+ *height
- buffer
->Ymax
- 1);
98 * Try to do a fast and simple RGB(a) glDrawPixels.
99 * Return: GL_TRUE if success, GL_FALSE if slow path must be used instead
102 simple_DrawPixels( GLcontext
*ctx
, GLint x
, GLint y
,
103 GLsizei width
, GLsizei height
, GLenum format
, GLenum type
,
104 const GLvoid
*pixels
)
106 const struct gl_pixelstore_attrib
*unpack
= &ctx
->Unpack
;
107 GLubyte rgb
[MAX_WIDTH
][3];
108 GLubyte rgba
[MAX_WIDTH
][4];
110 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx
, "glDrawPixels",
114 if (!ctx
->Current
.RasterPosValid
) {
119 if ((ctx
->RasterMask
&(~(SCISSOR_BIT
|WINCLIP_BIT
)))==0
120 && !ctx
->Pixel
.ScaleOrBiasRGBA
121 && !ctx
->Pixel
.ScaleOrBiasRGBApcm
122 && ctx
->ColorMatrix
.type
== MATRIX_IDENTITY
123 && !ctx
->Pixel
.ColorTableEnabled
124 && ctx
->Pixel
.IndexShift
==0 && ctx
->Pixel
.IndexOffset
==0
125 && ctx
->Pixel
.MapColorFlag
==0
126 && ctx
->Texture
.ReallyEnabled
== 0
127 && unpack
->Alignment
==1
128 && !unpack
->SwapBytes
129 && !unpack
->LsbFirst
) {
133 GLint drawWidth
= width
; /* actual width drawn */
134 GLint drawHeight
= height
; /* actual height drawn */
135 GLint skipPixels
= unpack
->SkipPixels
;
136 GLint skipRows
= unpack
->SkipRows
;
138 GLdepth zSpan
[MAX_WIDTH
]; /* only used when zooming */
141 if (unpack
->RowLength
> 0)
142 rowLength
= unpack
->RowLength
;
146 /* If we're not using pixel zoom then do all clipping calculations
147 * now. Otherwise, we'll let the gl_write_zoomed_*_span() functions
148 * handle the clipping.
150 if (ctx
->Pixel
.ZoomX
==1.0F
&& ctx
->Pixel
.ZoomY
==1.0F
) {
151 /* horizontal clipping */
152 if (destX
< ctx
->DrawBuffer
->Xmin
) {
153 skipPixels
+= (ctx
->DrawBuffer
->Xmin
- destX
);
154 drawWidth
-= (ctx
->DrawBuffer
->Xmin
- destX
);
155 destX
= ctx
->DrawBuffer
->Xmin
;
157 if (destX
+ drawWidth
> ctx
->DrawBuffer
->Xmax
)
158 drawWidth
-= (destX
+ drawWidth
- ctx
->DrawBuffer
->Xmax
- 1);
162 /* vertical clipping */
163 if (destY
< ctx
->DrawBuffer
->Ymin
) {
164 skipRows
+= (ctx
->DrawBuffer
->Ymin
- destY
);
165 drawHeight
-= (ctx
->DrawBuffer
->Ymin
- destY
);
166 destY
= ctx
->DrawBuffer
->Ymin
;
168 if (destY
+ drawHeight
> ctx
->DrawBuffer
->Ymax
)
169 drawHeight
-= (destY
+ drawHeight
- ctx
->DrawBuffer
->Ymax
- 1);
173 zoomY0
= 0; /* not used - silence compiler warning */
176 /* setup array of fragment Z value to pass to zoom function */
177 GLdepth z
= (GLdepth
) (ctx
->Current
.RasterPos
[2] * ctx
->Visual
->DepthMaxF
);
179 assert(drawWidth
< MAX_WIDTH
);
180 for (i
=0; i
<drawWidth
; i
++)
183 /* save Y value of first row */
184 zoomY0
= (GLint
) (ctx
->Current
.RasterPos
[1] + 0.5F
);
190 * The window region at (destX, destY) of size (drawWidth, drawHeight)
191 * will be written to.
192 * We'll take pixel data from buffer pointed to by "pixels" but we'll
193 * skip "skipRows" rows and skip "skipPixels" pixels/row.
196 if (format
==GL_RGBA
&& type
==GL_UNSIGNED_BYTE
) {
197 if (ctx
->Visual
->RGBAflag
) {
198 GLubyte
*src
= (GLubyte
*) pixels
199 + (skipRows
* rowLength
+ skipPixels
) * 4;
200 if (ctx
->Pixel
.ZoomX
==1.0F
&& ctx
->Pixel
.ZoomY
==1.0F
) {
203 for (row
=0; row
<drawHeight
; row
++) {
204 (*ctx
->Driver
.WriteRGBASpan
)(ctx
, drawWidth
, destX
, destY
,
206 src
+= rowLength
* 4;
213 for (row
=0; row
<drawHeight
; row
++) {
214 gl_write_zoomed_rgba_span(ctx
, drawWidth
, destX
, destY
,
215 zSpan
, (void *) src
, zoomY0
);
216 src
+= rowLength
* 4;
223 else if (format
==GL_RGB
&& type
==GL_UNSIGNED_BYTE
) {
224 if (ctx
->Visual
->RGBAflag
) {
225 GLubyte
*src
= (GLubyte
*) pixels
226 + (skipRows
* rowLength
+ skipPixels
) * 3;
227 if (ctx
->Pixel
.ZoomX
==1.0F
&& ctx
->Pixel
.ZoomY
==1.0F
) {
229 for (row
=0; row
<drawHeight
; row
++) {
230 (*ctx
->Driver
.WriteRGBSpan
)(ctx
, drawWidth
, destX
, destY
,
232 src
+= rowLength
* 3;
239 for (row
=0; row
<drawHeight
; row
++) {
240 gl_write_zoomed_rgb_span(ctx
, drawWidth
, destX
, destY
,
241 zSpan
, (void *) src
, zoomY0
);
242 src
+= rowLength
* 3;
249 else if (format
==GL_LUMINANCE
&& type
==GL_UNSIGNED_BYTE
) {
250 if (ctx
->Visual
->RGBAflag
) {
251 GLubyte
*src
= (GLubyte
*) pixels
252 + (skipRows
* rowLength
+ skipPixels
);
253 if (ctx
->Pixel
.ZoomX
==1.0F
&& ctx
->Pixel
.ZoomY
==1.0F
) {
256 assert(drawWidth
< MAX_WIDTH
);
257 for (row
=0; row
<drawHeight
; row
++) {
259 for (i
=0;i
<drawWidth
;i
++) {
264 (*ctx
->Driver
.WriteRGBSpan
)(ctx
, drawWidth
, destX
, destY
,
273 assert(drawWidth
< MAX_WIDTH
);
274 for (row
=0; row
<drawHeight
; row
++) {
276 for (i
=0;i
<drawWidth
;i
++) {
281 gl_write_zoomed_rgb_span(ctx
, drawWidth
, destX
, destY
,
282 zSpan
, (void *) rgb
, zoomY0
);
290 else if (format
==GL_LUMINANCE_ALPHA
&& type
==GL_UNSIGNED_BYTE
) {
291 if (ctx
->Visual
->RGBAflag
) {
292 GLubyte
*src
= (GLubyte
*) pixels
293 + (skipRows
* rowLength
+ skipPixels
)*2;
294 if (ctx
->Pixel
.ZoomX
==1.0F
&& ctx
->Pixel
.ZoomY
==1.0F
) {
297 assert(drawWidth
< MAX_WIDTH
);
298 for (row
=0; row
<drawHeight
; row
++) {
301 for (i
=0;i
<drawWidth
;i
++) {
307 (*ctx
->Driver
.WriteRGBASpan
)(ctx
, drawWidth
, destX
, destY
,
308 (void *) rgba
, NULL
);
316 assert(drawWidth
< MAX_WIDTH
);
317 for (row
=0; row
<drawHeight
; row
++) {
320 for (i
=0;i
<drawWidth
;i
++) {
326 gl_write_zoomed_rgba_span(ctx
, drawWidth
, destX
, destY
,
327 zSpan
, (void *) rgba
, zoomY0
);
335 else if (format
==GL_COLOR_INDEX
&& type
==GL_UNSIGNED_BYTE
) {
336 GLubyte
*src
= (GLubyte
*) pixels
+ skipRows
* rowLength
+ skipPixels
;
337 if (ctx
->Visual
->RGBAflag
) {
338 /* convert CI data to RGBA */
339 if (ctx
->Pixel
.ZoomX
==1.0F
&& ctx
->Pixel
.ZoomY
==1.0F
) {
342 for (row
=0; row
<drawHeight
; row
++) {
343 assert(drawWidth
< MAX_WIDTH
);
344 _mesa_map_ci8_to_rgba(ctx
, drawWidth
, src
, rgba
);
345 (*ctx
->Driver
.WriteRGBASpan
)(ctx
, drawWidth
, destX
, destY
,
346 (const GLubyte (*)[4])rgba
,
356 for (row
=0; row
<drawHeight
; row
++) {
357 assert(drawWidth
< MAX_WIDTH
);
358 _mesa_map_ci8_to_rgba(ctx
, drawWidth
, src
, rgba
);
359 gl_write_zoomed_rgba_span(ctx
, drawWidth
, destX
, destY
,
360 zSpan
, (void *) rgba
, zoomY0
);
368 /* write CI data to CI frame buffer */
370 if (ctx
->Pixel
.ZoomX
==1.0F
&& ctx
->Pixel
.ZoomY
==1.0F
) {
372 for (row
=0; row
<drawHeight
; row
++) {
373 (*ctx
->Driver
.WriteCI8Span
)(ctx
, drawWidth
, destX
, destY
,
387 /* can't handle this pixel format and/or data type here */
392 /* can't do a simple draw, have to use slow path */
399 * Do glDrawPixels of index pixels.
402 draw_index_pixels( GLcontext
*ctx
, GLint x
, GLint y
,
403 GLsizei width
, GLsizei height
,
404 GLenum type
, const GLvoid
*pixels
)
406 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!=1.0 || ctx
->Pixel
.ZoomY
!=1.0;
407 const GLint desty
= y
;
408 GLint row
, drawWidth
;
409 GLdepth zspan
[MAX_WIDTH
];
411 drawWidth
= (width
> MAX_WIDTH
) ? MAX_WIDTH
: width
;
413 /* Fragment depth values */
414 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
) {
415 GLdepth zval
= (GLdepth
) (ctx
->Current
.RasterPos
[2] * ctx
->Visual
->DepthMaxF
);
417 for (i
= 0; i
< drawWidth
; i
++) {
425 for (row
= 0; row
< height
; row
++, y
++) {
426 GLuint indexes
[MAX_WIDTH
];
427 const GLvoid
*source
= _mesa_image_address(&ctx
->Unpack
,
428 pixels
, width
, height
, GL_COLOR_INDEX
, type
, 0, row
, 0);
429 _mesa_unpack_index_span(ctx
, drawWidth
, GL_UNSIGNED_INT
, indexes
,
430 type
, source
, &ctx
->Unpack
, GL_TRUE
);
432 gl_write_zoomed_index_span(ctx
, drawWidth
, x
, y
, zspan
, indexes
, desty
);
435 gl_write_index_span(ctx
, drawWidth
, x
, y
, zspan
, indexes
, GL_BITMAP
);
443 * Do glDrawPixels of stencil image. The image datatype may either
444 * be GLubyte or GLbitmap.
447 draw_stencil_pixels( GLcontext
*ctx
, GLint x
, GLint y
,
448 GLsizei width
, GLsizei height
,
449 GLenum type
, const GLvoid
*pixels
)
451 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!=1.0 || ctx
->Pixel
.ZoomY
!=1.0;
452 const GLboolean shift_or_offset
= ctx
->Pixel
.IndexShift
|| ctx
->Pixel
.IndexOffset
;
453 const GLint desty
= y
;
454 GLint row
, drawWidth
;
456 if (type
!= GL_BYTE
&&
457 type
!= GL_UNSIGNED_BYTE
&&
459 type
!= GL_UNSIGNED_SHORT
&&
461 type
!= GL_UNSIGNED_INT
&&
464 gl_error( ctx
, GL_INVALID_ENUM
, "glDrawPixels(stencil type)");
468 drawWidth
= (width
> MAX_WIDTH
) ? MAX_WIDTH
: width
;
470 for (row
= 0; row
< height
; row
++, y
++) {
471 GLstencil values
[MAX_WIDTH
];
472 GLenum destType
= (sizeof(GLstencil
) == sizeof(GLubyte
))
473 ? GL_UNSIGNED_BYTE
: GL_UNSIGNED_SHORT
;
474 const GLvoid
*source
= _mesa_image_address(&ctx
->Unpack
,
475 pixels
, width
, height
, GL_COLOR_INDEX
, type
, 0, row
, 0);
476 _mesa_unpack_index_span(ctx
, drawWidth
, destType
, values
,
477 type
, source
, &ctx
->Unpack
, GL_FALSE
);
478 if (shift_or_offset
) {
479 _mesa_shift_and_offset_stencil( ctx
, drawWidth
, values
);
481 if (ctx
->Pixel
.MapStencilFlag
) {
482 _mesa_map_stencil( ctx
, drawWidth
, values
);
486 gl_write_zoomed_stencil_span( ctx
, (GLuint
) drawWidth
, x
, y
,
490 _mesa_write_stencil_span( ctx
, (GLuint
) drawWidth
, x
, y
, values
);
498 * Do a glDrawPixels of depth values.
501 draw_depth_pixels( GLcontext
*ctx
, GLint x
, GLint y
,
502 GLsizei width
, GLsizei height
,
503 GLenum type
, const GLvoid
*pixels
)
505 const GLboolean bias_or_scale
= ctx
->Pixel
.DepthBias
!=0.0 || ctx
->Pixel
.DepthScale
!=1.0;
506 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!=1.0 || ctx
->Pixel
.ZoomY
!=1.0;
507 const GLint desty
= y
;
508 GLubyte rgba
[MAX_WIDTH
][4];
509 GLuint ispan
[MAX_WIDTH
];
510 GLint drawWidth
= (width
> MAX_WIDTH
) ? MAX_WIDTH
: width
;
512 if (type
!= GL_UNSIGNED_BYTE
513 && type
!= GL_UNSIGNED_BYTE
514 && type
!= GL_UNSIGNED_SHORT
515 && type
!= GL_UNSIGNED_SHORT
516 && type
!= GL_UNSIGNED_INT
517 && type
!= GL_UNSIGNED_INT
518 && type
!= GL_FLOAT
) {
519 gl_error(ctx
, GL_INVALID_ENUM
, "glDrawPixels(type)");
523 /* Colors or indexes */
524 if (ctx
->Visual
->RGBAflag
) {
525 GLint r
= (GLint
) (ctx
->Current
.RasterColor
[0] * 255.0F
);
526 GLint g
= (GLint
) (ctx
->Current
.RasterColor
[1] * 255.0F
);
527 GLint b
= (GLint
) (ctx
->Current
.RasterColor
[2] * 255.0F
);
528 GLint a
= (GLint
) (ctx
->Current
.RasterColor
[3] * 255.0F
);
530 for (i
= 0; i
< drawWidth
; i
++) {
539 for (i
= 0; i
< drawWidth
; i
++) {
540 ispan
[i
] = ctx
->Current
.RasterIndex
;
544 if (type
==GL_UNSIGNED_SHORT
&& sizeof(GLdepth
)==sizeof(GLushort
)
545 && !bias_or_scale
&& !zoom
&& ctx
->Visual
->RGBAflag
) {
546 /* Special case: directly write 16-bit depth values */
548 for (row
= 0; row
< height
; row
++, y
++) {
549 GLdepth zspan
[MAX_WIDTH
];
550 const GLushort
*zptr
= _mesa_image_address(&ctx
->Unpack
,
551 pixels
, width
, height
, GL_DEPTH_COMPONENT
, type
, 0, row
, 0);
553 for (i
= 0; i
< width
; i
++)
555 gl_write_rgba_span( ctx
, width
, x
, y
, zspan
, rgba
, GL_BITMAP
);
558 else if (type
==GL_UNSIGNED_INT
&& ctx
->Visual
->DepthBits
== 32
559 && !bias_or_scale
&& !zoom
&& ctx
->Visual
->RGBAflag
) {
560 /* Special case: directly write 32-bit depth values */
562 for (row
= 0; row
< height
; row
++, y
++) {
563 const GLuint
*zptr
= _mesa_image_address(&ctx
->Unpack
,
564 pixels
, width
, height
, GL_DEPTH_COMPONENT
, type
, 0, row
, 0);
565 gl_write_rgba_span( ctx
, width
, x
, y
, zptr
, rgba
, GL_BITMAP
);
571 for (row
= 0; row
< height
; row
++, y
++) {
572 GLdepth zspan
[MAX_WIDTH
];
573 const GLvoid
*src
= _mesa_image_address(&ctx
->Unpack
,
574 pixels
, width
, height
, GL_DEPTH_COMPONENT
, type
, 0, row
, 0);
575 _mesa_unpack_depth_span( ctx
, drawWidth
, zspan
, type
, src
,
576 &ctx
->Unpack
, GL_TRUE
);
577 if (ctx
->Visual
->RGBAflag
) {
579 gl_write_zoomed_rgba_span(ctx
, width
, x
, y
, zspan
,
580 (const GLubyte (*)[4])rgba
, desty
);
583 gl_write_rgba_span(ctx
, width
, x
, y
, zspan
, rgba
, GL_BITMAP
);
588 gl_write_zoomed_index_span(ctx
, width
, x
, y
, zspan
,
592 gl_write_index_span(ctx
, width
, x
, y
, zspan
, ispan
, GL_BITMAP
);
602 * Do glDrawPixels of RGBA pixels.
605 draw_rgba_pixels( GLcontext
*ctx
, GLint x
, GLint y
,
606 GLsizei width
, GLsizei height
,
607 GLenum format
, GLenum type
, const GLvoid
*pixels
)
609 const struct gl_pixelstore_attrib
*unpack
= &ctx
->Unpack
;
610 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!=1.0 || ctx
->Pixel
.ZoomY
!=1.0;
611 const GLint desty
= y
;
612 GLdepth zspan
[MAX_WIDTH
];
615 /* Try an optimized glDrawPixels first */
616 if (simple_DrawPixels(ctx
, x
, y
, width
, height
, format
, type
, pixels
))
619 /* Fragment depth values */
620 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
) {
621 /* fill in array of z values */
622 GLdepth z
= (GLdepth
) (ctx
->Current
.RasterPos
[2] * ctx
->Visual
->DepthMaxF
);
624 for (i
=0;i
<width
;i
++) {
630 if (ctx
->RasterMask
== 0 && !zoom
632 && x
+ width
<= ctx
->DrawBuffer
->Width
633 && y
+ height
<= ctx
->DrawBuffer
->Height
) {
637 quickDraw
= GL_FALSE
;
644 GLubyte rgba
[MAX_WIDTH
][4];
646 if (width
> MAX_WIDTH
)
648 for (row
= 0; row
< height
; row
++, y
++) {
649 const GLvoid
*source
= _mesa_image_address(unpack
,
650 pixels
, width
, height
, format
, type
, 0, row
, 0);
651 _mesa_unpack_ubyte_color_span(ctx
, width
, GL_RGBA
, (void*) rgba
,
652 format
, type
, source
, unpack
, GL_TRUE
);
654 if (ctx
->Texture
.ReallyEnabled
&& ctx
->Pixel
.PixelTextureEnabled
) {
655 GLfloat s
[MAX_WIDTH
], t
[MAX_WIDTH
], r
[MAX_WIDTH
], q
[MAX_WIDTH
];
657 /* XXX not sure how multitexture is supposed to work here */
658 for (unit
= 0; unit
< MAX_TEXTURE_UNITS
; unit
++) {
659 _mesa_pixeltexgen(ctx
, width
, (const GLubyte (*)[4]) rgba
,
661 gl_texture_pixels(ctx
, unit
, width
, s
, t
, r
, NULL
, rgba
);
666 (*ctx
->Driver
.WriteRGBASpan
)( ctx
, width
, x
, y
,
667 (CONST
GLubyte (*)[]) rgba
, NULL
);
670 gl_write_zoomed_rgba_span( ctx
, width
, x
, y
, zspan
,
671 (CONST
GLubyte (*)[]) rgba
, desty
);
674 gl_write_rgba_span( ctx
, (GLuint
) width
, x
, y
, zspan
, rgba
, GL_BITMAP
);
683 * Execute glDrawPixels
686 _mesa_DrawPixels( GLsizei width
, GLsizei height
,
687 GLenum format
, GLenum type
, const GLvoid
*pixels
)
689 GET_CURRENT_CONTEXT(ctx
);
690 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glDrawPixels");
692 if (ctx
->RenderMode
==GL_RENDER
) {
694 if (!pixels
|| !ctx
->Current
.RasterPosValid
) {
699 gl_update_state(ctx
);
702 x
= (GLint
) (ctx
->Current
.RasterPos
[0] + 0.5F
);
703 y
= (GLint
) (ctx
->Current
.RasterPos
[1] + 0.5F
);
705 ctx
->OcclusionResult
= GL_TRUE
;
707 /* see if device driver can do the drawpix */
708 if (ctx
->Driver
.DrawPixels
709 && (*ctx
->Driver
.DrawPixels
)(ctx
, x
, y
, width
, height
, format
, type
,
710 &ctx
->Unpack
, pixels
)) {
715 case GL_STENCIL_INDEX
:
716 draw_stencil_pixels( ctx
, x
, y
, width
, height
, type
, pixels
);
718 case GL_DEPTH_COMPONENT
:
719 draw_depth_pixels( ctx
, x
, y
, width
, height
, type
, pixels
);
722 if (ctx
->Visual
->RGBAflag
)
723 draw_rgba_pixels(ctx
, x
,y
, width
, height
, format
, type
, pixels
);
725 draw_index_pixels(ctx
, x
, y
, width
, height
, type
, pixels
);
732 case GL_LUMINANCE_ALPHA
:
738 draw_rgba_pixels(ctx
, x
, y
, width
, height
, format
, type
, pixels
);
741 gl_error( ctx
, GL_INVALID_ENUM
, "glDrawPixels(format)" );
745 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
746 if (ctx
->Current
.RasterPosValid
) {
748 GLfloat texcoord
[4], invq
;
749 UBYTE_RGBA_TO_FLOAT_RGBA(color
, ctx
->Current
.ByteColor
);
750 invq
= 1.0F
/ ctx
->Current
.Texcoord
[0][3];
751 texcoord
[0] = ctx
->Current
.Texcoord
[0][0] * invq
;
752 texcoord
[1] = ctx
->Current
.Texcoord
[0][1] * invq
;
753 texcoord
[2] = ctx
->Current
.Texcoord
[0][2] * invq
;
754 texcoord
[3] = ctx
->Current
.Texcoord
[0][3];
755 FEEDBACK_TOKEN( ctx
, (GLfloat
) (GLint
) GL_DRAW_PIXEL_TOKEN
);
756 gl_feedback_vertex( ctx
,
757 ctx
->Current
.RasterPos
,
758 color
, ctx
->Current
.Index
, texcoord
);
761 else if (ctx
->RenderMode
==GL_SELECT
) {
762 if (ctx
->Current
.RasterPosValid
) {
763 gl_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );