Moved software rasterizer functionality to new directory.
[mesa.git] / src / mesa / swrast / s_pixeltex.c
1 /* $Id: s_pixeltex.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2000 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_pixeltex.h"
40
41
42 /*
43 * Convert RGBA values into strq texture coordinates.
44 */
45 void
46 _mesa_pixeltexgen(GLcontext *ctx, GLuint n, const GLchan rgba[][4],
47 GLfloat s[], GLfloat t[], GLfloat r[], GLfloat q[])
48 {
49 if (ctx->Pixel.FragmentRgbSource == GL_CURRENT_RASTER_COLOR) {
50 GLuint i;
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];
55 }
56 }
57 else {
58 GLuint i;
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]);
64 }
65 }
66
67 if (ctx->Pixel.FragmentAlphaSource == GL_CURRENT_RASTER_COLOR) {
68 GLuint i;
69 for (i = 0; i < n; i++) {
70 q[i] = ctx->Current.RasterColor[ACOMP];
71 }
72 }
73 else {
74 GLuint i;
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]);
78 }
79 }
80 }