e51f8369a1ef97e53e4caa992a609d031eed2d05
1 /* $Id: drawpix.c,v 1.53 2001/04/28 08:39:17 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 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.
48 * Execute glDrawPixels
51 _mesa_DrawPixels( GLsizei width
, GLsizei height
,
52 GLenum format
, GLenum type
, const GLvoid
*pixels
)
54 GET_CURRENT_CONTEXT(ctx
);
55 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
57 if (ctx
->RenderMode
==GL_RENDER
) {
59 if (!pixels
|| !ctx
->Current
.RasterPosValid
) {
64 _mesa_update_state(ctx
);
67 x
= IROUND(ctx
->Current
.RasterPos
[0]);
68 y
= IROUND(ctx
->Current
.RasterPos
[1]);
70 ctx
->OcclusionResult
= GL_TRUE
;
71 ctx
->Driver
.DrawPixels(ctx
, x
, y
, width
, height
, format
, type
,
72 &ctx
->Unpack
, pixels
);
74 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
75 if (ctx
->Current
.RasterPosValid
) {
76 GLfloat texcoord
[4], invq
;
78 FLUSH_CURRENT(ctx
, 0);
79 invq
= 1.0F
/ ctx
->Current
.Texcoord
[0][3];
80 texcoord
[0] = ctx
->Current
.Texcoord
[0][0] * invq
;
81 texcoord
[1] = ctx
->Current
.Texcoord
[0][1] * invq
;
82 texcoord
[2] = ctx
->Current
.Texcoord
[0][2] * invq
;
83 texcoord
[3] = ctx
->Current
.Texcoord
[0][3];
84 FEEDBACK_TOKEN( ctx
, (GLfloat
) (GLint
) GL_DRAW_PIXEL_TOKEN
);
85 _mesa_feedback_vertex( ctx
,
86 ctx
->Current
.RasterPos
,
92 else if (ctx
->RenderMode
==GL_SELECT
) {
93 if (ctx
->Current
.RasterPosValid
) {
94 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );