diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2002-01-27 18:32:03 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2002-01-27 18:32:03 +0000 |
commit | 2a182a98973edc9ecf2936b1288485bb2b3fa722 (patch) | |
tree | 4c832bef597d1cbbccb7e7ab80f508aac2bbaba9 /src/mesa/swrast/s_pixeltex.c | |
parent | 6a731f343e847226537080122e2fb327e2486564 (diff) | |
download | external_mesa3d-2a182a98973edc9ecf2936b1288485bb2b3fa722.zip external_mesa3d-2a182a98973edc9ecf2936b1288485bb2b3fa722.tar.gz external_mesa3d-2a182a98973edc9ecf2936b1288485bb2b3fa722.tar.bz2 |
LOTS of changes, building upon Klaus's work.
struct sw_span is used throughout span/fragment processing.
This is leading to less code and more chances for optimization.
Diffstat (limited to 'src/mesa/swrast/s_pixeltex.c')
-rw-r--r-- | src/mesa/swrast/s_pixeltex.c | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/src/mesa/swrast/s_pixeltex.c b/src/mesa/swrast/s_pixeltex.c index 88a20e5..cbebeaf 100644 --- a/src/mesa/swrast/s_pixeltex.c +++ b/src/mesa/swrast/s_pixeltex.c @@ -1,4 +1,4 @@ -/* $Id: s_pixeltex.c,v 1.4 2002/01/10 16:54:29 brianp Exp $ */ +/* $Id: s_pixeltex.c,v 1.5 2002/01/27 18:32:03 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -35,17 +35,19 @@ #include "glheader.h" #include "colormac.h" +#include "mem.h" #include "s_context.h" #include "s_pixeltex.h" +#include "s_texture.h" /* * Convert RGBA values into strq texture coordinates. */ -void -_mesa_pixeltexgen(GLcontext *ctx, GLuint n, const GLchan rgba[][4], - GLfloat texcoord[][4]) +static void +pixeltexgen(GLcontext *ctx, GLuint n, const GLchan rgba[][4], + GLfloat texcoord[][4]) { if (ctx->Pixel.FragmentRgbSource == GL_CURRENT_RASTER_COLOR) { GLuint i; @@ -79,3 +81,41 @@ _mesa_pixeltexgen(GLcontext *ctx, GLuint n, const GLchan rgba[][4], } } } + + + +/* + * Used byglDraw/CopyPixels: the incoming image colors are treated + * as texture coordinates. Use those coords to texture the image. + * This is for GL_SGIS_pixel_texture / GL_SGIX_pixel_texture. + */ +void +_swrast_pixel_texture(GLcontext *ctx, struct sw_span *span) +{ + if (ctx->Texture._ReallyEnabled & ~TEXTURE0_ANY) { + /* multitexture! */ + GLchan rgbaOut[MAX_WIDTH][4]; + GLuint unit; + + MEMCPY(rgbaOut, span->color.rgba, 4 * span->end * sizeof(GLchan)); + + for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { + if (ctx->Texture.Unit[unit]._ReallyEnabled) { + pixeltexgen(ctx, span->end, + (const GLchan (*)[4]) span->color.rgba, + span->texcoords[unit]); + _swrast_texture_fragments(ctx, unit, span, rgbaOut); + } + } + + MEMCPY(span->color.rgba, rgbaOut, 4 * span->end * sizeof(GLchan)); + } + else { + /* single texture, unit 0 */ + ASSERT(ctx->Texture._ReallyEnabled & TEXTURE0_ANY); + pixeltexgen(ctx, span->end, + (const GLchan (*)[4]) span->color.rgba, + span->texcoords[0]); + _swrast_texture_fragments(ctx, 0, span, span->color.rgba); + } +} |