1 /* $Id: s_pixeltex.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.
29 * This file implements both the GL_SGIX_pixel_texture and
30 * GL_SIGS_pixel_texture extensions. Luckily, they pretty much
31 * overlap in functionality so we use the same state variables
32 * and execution code for both.
39 #include "s_pixeltex.h"
43 * Convert RGBA values into strq texture coordinates.
46 _mesa_pixeltexgen(GLcontext
*ctx
, GLuint n
, const GLchan rgba
[][4],
47 GLfloat s
[], GLfloat t
[], GLfloat r
[], GLfloat q
[])
49 if (ctx
->Pixel
.FragmentRgbSource
== GL_CURRENT_RASTER_COLOR
) {
51 for (i
= 0; i
< n
; i
++) {
52 s
[i
] = ctx
->Current
.RasterColor
[RCOMP
];
53 t
[i
] = ctx
->Current
.RasterColor
[GCOMP
];
54 r
[i
] = ctx
->Current
.RasterColor
[BCOMP
];
59 ASSERT(ctx
->Pixel
.FragmentRgbSource
== GL_PIXEL_GROUP_COLOR_SGIS
);
60 for (i
= 0; i
< n
; i
++) {
61 s
[i
] = CHAN_TO_FLOAT(rgba
[i
][RCOMP
]);
62 t
[i
] = CHAN_TO_FLOAT(rgba
[i
][GCOMP
]);
63 r
[i
] = CHAN_TO_FLOAT(rgba
[i
][BCOMP
]);
67 if (ctx
->Pixel
.FragmentAlphaSource
== GL_CURRENT_RASTER_COLOR
) {
69 for (i
= 0; i
< n
; i
++) {
70 q
[i
] = ctx
->Current
.RasterColor
[ACOMP
];
75 ASSERT(ctx
->Pixel
.FragmentAlphaSource
== GL_PIXEL_GROUP_COLOR_SGIS
);
76 for (i
= 0; i
< n
; i
++) {
77 q
[i
] = CHAN_TO_FLOAT(rgba
[i
][ACOMP
]);