1 /* $Id: s_pixeltex.c,v 1.3 2001/03/12 00:48:42 gareth 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.
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_context.h"
40 #include "s_pixeltex.h"
44 * Convert RGBA values into strq texture coordinates.
47 _mesa_pixeltexgen(GLcontext
*ctx
, GLuint n
, const GLchan rgba
[][4],
48 GLfloat s
[], GLfloat t
[], GLfloat r
[], GLfloat q
[])
50 if (ctx
->Pixel
.FragmentRgbSource
== GL_CURRENT_RASTER_COLOR
) {
52 for (i
= 0; i
< n
; i
++) {
53 s
[i
] = ctx
->Current
.RasterColor
[RCOMP
];
54 t
[i
] = ctx
->Current
.RasterColor
[GCOMP
];
55 r
[i
] = ctx
->Current
.RasterColor
[BCOMP
];
60 ASSERT(ctx
->Pixel
.FragmentRgbSource
== GL_PIXEL_GROUP_COLOR_SGIS
);
61 for (i
= 0; i
< n
; i
++) {
62 s
[i
] = CHAN_TO_FLOAT(rgba
[i
][RCOMP
]);
63 t
[i
] = CHAN_TO_FLOAT(rgba
[i
][GCOMP
]);
64 r
[i
] = CHAN_TO_FLOAT(rgba
[i
][BCOMP
]);
68 if (ctx
->Pixel
.FragmentAlphaSource
== GL_CURRENT_RASTER_COLOR
) {
70 for (i
= 0; i
< n
; i
++) {
71 q
[i
] = ctx
->Current
.RasterColor
[ACOMP
];
76 ASSERT(ctx
->Pixel
.FragmentAlphaSource
== GL_PIXEL_GROUP_COLOR_SGIS
);
77 for (i
= 0; i
< n
; i
++) {
78 q
[i
] = CHAN_TO_FLOAT(rgba
[i
][ACOMP
]);