Klaus's latest patches: change texcoord[3] to texcoord[4] everywhere
[mesa.git] / src / mesa / swrast / s_pixeltex.c
1 /* $Id: s_pixeltex.c,v 1.4 2002/01/10 16:54:29 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 4.1
6 *
7 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
8 *
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:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
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.
25 */
26
27
28 /*
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.
33 */
34
35
36 #include "glheader.h"
37 #include "colormac.h"
38
39 #include "s_context.h"
40 #include "s_pixeltex.h"
41
42
43 /*
44 * Convert RGBA values into strq texture coordinates.
45 */
46 void
47 _mesa_pixeltexgen(GLcontext *ctx, GLuint n, const GLchan rgba[][4],
48 GLfloat texcoord[][4])
49 {
50 if (ctx->Pixel.FragmentRgbSource == GL_CURRENT_RASTER_COLOR) {
51 GLuint i;
52 for (i = 0; i < n; i++) {
53 texcoord[i][0] = ctx->Current.RasterColor[RCOMP];
54 texcoord[i][1] = ctx->Current.RasterColor[GCOMP];
55 texcoord[i][2] = ctx->Current.RasterColor[BCOMP];
56 }
57 }
58 else {
59 GLuint i;
60 ASSERT(ctx->Pixel.FragmentRgbSource == GL_PIXEL_GROUP_COLOR_SGIS);
61 for (i = 0; i < n; i++) {
62 texcoord[i][0] = CHAN_TO_FLOAT(rgba[i][RCOMP]);
63 texcoord[i][1] = CHAN_TO_FLOAT(rgba[i][GCOMP]);
64 texcoord[i][2] = CHAN_TO_FLOAT(rgba[i][BCOMP]);
65 }
66 }
67
68 if (ctx->Pixel.FragmentAlphaSource == GL_CURRENT_RASTER_COLOR) {
69 GLuint i;
70 for (i = 0; i < n; i++) {
71 texcoord[i][3] = ctx->Current.RasterColor[ACOMP];
72 }
73 }
74 else {
75 GLuint i;
76 ASSERT(ctx->Pixel.FragmentAlphaSource == GL_PIXEL_GROUP_COLOR_SGIS);
77 for (i = 0; i < n; i++) {
78 texcoord[i][3] = CHAN_TO_FLOAT(rgba[i][ACOMP]);
79 }
80 }
81 }