diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/attrib.c | 5 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 6 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 4 | ||||
-rw-r--r-- | src/mesa/main/state.c | 7 | ||||
-rw-r--r-- | src/mesa/main/texobj.c | 3 | ||||
-rw-r--r-- | src/mesa/main/texstate.c | 32 | ||||
-rw-r--r-- | src/mesa/swrast/s_copypix.c | 8 | ||||
-rw-r--r-- | src/mesa/swrast/s_drawpix.c | 5 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.c | 16 | ||||
-rw-r--r-- | src/mesa/swrast/s_texture.c | 175 | ||||
-rw-r--r-- | src/mesa/swrast/s_texture.h | 6 |
11 files changed, 169 insertions, 98 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 205c14b0241..746ca7332b4 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1,4 +1,4 @@ -/* $Id: attrib.c,v 1.43 2001/01/29 22:15:44 brianp Exp $ */ +/* $Id: attrib.c,v 1.44 2001/02/20 16:42:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -101,6 +101,9 @@ copy_texobj_state( struct gl_texture_object *dest, dest->MaxLod = src->MaxLod; dest->BaseLevel = src->BaseLevel; dest->MaxLevel = src->MaxLevel; + dest->CompareFlag = src->CompareFlag; + dest->CompareOperator = src->CompareOperator; + dest->ShadowAmbient = src->ShadowAmbient; dest->_MaxLevel = src->_MaxLevel; dest->_MaxLambda = src->_MaxLambda; dest->Palette = src->Palette; diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index c68d751d322..a0b562378ef 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -1,4 +1,4 @@ -/* $Id: extensions.c,v 1.47 2001/02/17 18:41:01 brianp Exp $ */ +/* $Id: extensions.c,v 1.48 2001/02/20 16:42:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -105,6 +105,7 @@ static struct { { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, { OFF, "GL_SGIX_depth_texture", F(SGIX_depth_texture) }, { OFF, "GL_SGIX_shadow", F(SGIX_shadow) }, + { OFF, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient) }, { ON, "GL_SGIX_pixel_texture", F(SGIX_pixel_texture) }, { OFF, "GL_3DFX_texture_compression_FXT1", F(_3DFX_texture_compression_FXT1) } }; @@ -127,7 +128,8 @@ _mesa_enable_sw_extensions(GLcontext *ctx) gl_extensions_enable(ctx, "GL_NV_blend_square"); gl_extensions_enable(ctx, "GL_MESA_sprite_point"); gl_extensions_enable(ctx, "GL_SGIX_depth_texture"); - /*gl_extensions_enable(ctx, "GL_SGIX_shadow"); not finished */ + gl_extensions_enable(ctx, "GL_SGIX_shadow"); + gl_extensions_enable(ctx, "GL_SGIX_shadow_ambient"); } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index b890fa0dbd0..93e76e57294 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.20 2001/02/17 18:41:01 brianp Exp $ */ +/* $Id: mtypes.h,v 1.21 2001/02/20 16:42:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -834,6 +834,7 @@ struct gl_texture_object { GLint MaxLevel; /* max mipmap level, OpenGL 1.2 */ GLboolean CompareFlag; /* GL_SGIX_shadow */ GLenum CompareOperator; /* GL_SGIX_shadow */ + GLchan ShadowAmbient; /* GL_SGIX_shadow_ambient */ GLint _MaxLevel; /* actual max mipmap level (q in the spec) */ GLfloat _MaxLambda; /* = _MaxLevel - BaseLevel (q - b in spec) */ struct gl_texture_image *Image[MAX_TEXTURE_LEVELS]; @@ -1230,6 +1231,7 @@ struct gl_extensions { GLboolean SGIX_depth_texture; GLboolean SGIX_pixel_texture; GLboolean SGIX_shadow; + GLboolean SGIX_shadow_ambient; GLboolean _3DFX_texture_compression_FXT1; }; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 533fa687242..badf180ce88 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1,4 +1,4 @@ -/* $Id: state.c,v 1.58 2001/02/16 00:35:35 keithw Exp $ */ +/* $Id: state.c,v 1.59 2001/02/20 16:42:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -993,6 +993,11 @@ void gl_update_state( GLcontext *ctx ) ASSERT(ctx->Driver.TexSubImage1D); ASSERT(ctx->Driver.TexSubImage2D); ASSERT(ctx->Driver.TexSubImage3D); + ASSERT(ctx->Driver.CopyTexImage1D); + ASSERT(ctx->Driver.CopyTexImage2D); + ASSERT(ctx->Driver.CopyTexSubImage1D); + ASSERT(ctx->Driver.CopyTexSubImage2D); + ASSERT(ctx->Driver.CopyTexSubImage3D); if (ctx->Extensions.ARB_texture_compression) { ASSERT(ctx->Driver.CompressedTexImage1D); ASSERT(ctx->Driver.CompressedTexImage2D); diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 95427855fba..b227a96192c 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -1,4 +1,4 @@ -/* $Id: texobj.c,v 1.39 2001/02/17 18:41:01 brianp Exp $ */ +/* $Id: texobj.c,v 1.40 2001/02/20 16:42:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -81,6 +81,7 @@ _mesa_alloc_texture_object( struct gl_shared_state *shared, obj->MaxLevel = 1000; obj->CompareFlag = GL_FALSE; obj->CompareOperator = GL_TEXTURE_LEQUAL_R_SGIX; + obj->ShadowAmbient = 0; _mesa_init_colortable(&obj->Palette); /* insert into linked list */ diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index f55cb5452a0..607f3b77dcf 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -1,4 +1,4 @@ -/* $Id: texstate.c,v 1.32 2001/02/17 18:41:01 brianp Exp $ */ +/* $Id: texstate.c,v 1.33 2001/02/20 16:42:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -784,7 +784,7 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) GLenum op = (GLenum) params[0]; if (op == GL_TEXTURE_LEQUAL_R_SGIX || op == GL_TEXTURE_GEQUAL_R_SGIX) { - texObj->CompareFlag = (GLenum) op; + texObj->CompareOperator = op; } else { gl_error(ctx, GL_INVALID_ENUM, "glTexParameter(param)"); @@ -795,6 +795,15 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) return; } break; + case GL_SHADOW_AMBIENT_SGIX: + if (ctx->Extensions.SGIX_shadow_ambient) { + UNCLAMPED_FLOAT_TO_CHAN(texObj->ShadowAmbient, params[0]); + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname)"); + return; + } + break; default: gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(pname)" ); return; @@ -1064,6 +1073,15 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) return; } break; + case GL_SHADOW_AMBIENT_SGIX: + if (ctx->Extensions.SGIX_shadow_ambient) { + *params = CHAN_TO_FLOAT(obj->ShadowAmbient); + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)"); + return; + } + break; default: gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" ); } @@ -1156,6 +1174,16 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) return; } break; + case GL_SHADOW_AMBIENT_SGIX: + if (ctx->Extensions.SGIX_shadow_ambient) { + /* XXX range? */ + *params = CHAN_TO_FLOAT(obj->ShadowAmbient); + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)"); + return; + } + break; default: gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)" ); } diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 401955d00ae..4c4d0003178 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -1,4 +1,4 @@ -/* $Id: s_copypix.c,v 1.10 2001/01/23 23:39:37 brianp Exp $ */ +/* $Id: s_copypix.c,v 1.11 2001/02/20 16:42:26 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -248,7 +248,8 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, _mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba, s, t, r, q); _swrast_texture_fragments(ctx, unit, width, s, t, r, NULL, - primary_rgba, rgba); + (CONST GLchan (*)[4]) primary_rgba, + rgba); } } @@ -494,7 +495,8 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, _mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba, s, t, r, q); _swrast_texture_fragments(ctx, unit, width, s, t, r, NULL, - primary_rgba, rgba); + (CONST GLchan (*)[4]) primary_rgba, + rgba); } } diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 24339f61bbc..94d8d873a2a 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -1,4 +1,4 @@ -/* $Id: s_drawpix.c,v 1.9 2001/02/17 18:41:01 brianp Exp $ */ +/* $Id: s_drawpix.c,v 1.10 2001/02/20 16:42:26 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -821,7 +821,8 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, _mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba, s, t, r, q); _swrast_texture_fragments(ctx, unit, width, s, t, r, NULL, - primary_rgba, rgba); + (CONST GLchan (*)[4]) primary_rgba, + rgba); } } } diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index c2d946b35fb..cb62a8a10bf 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1,4 +1,4 @@ -/* $Id: s_span.c,v 1.8 2001/02/15 22:59:01 brianp Exp $ */ +/* $Id: s_span.c,v 1.9 2001/02/20 16:42:26 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -817,7 +817,8 @@ void gl_write_texture_span( GLcontext *ctx, /* Texturing without alpha is done after depth-testing which gives a potential speed-up. */ ASSERT(ctx->Texture._ReallyEnabled); - _swrast_texture_fragments( ctx, 0, n, s, t, u, lambda, rgba, rgba ); + _swrast_texture_fragments( ctx, 0, n, s, t, u, lambda, + (CONST GLchan (*)[4]) rgba, rgba ); /* Do the alpha test */ if (_mesa_alpha_test( ctx, n, (const GLchan (*)[4]) rgba, mask ) == 0) { @@ -850,7 +851,8 @@ void gl_write_texture_span( GLcontext *ctx, /* Texture without alpha test */ if (! ctx->Color.AlphaEnabled) { ASSERT(ctx->Texture._ReallyEnabled); - _swrast_texture_fragments( ctx, 0, n, s, t, u, lambda, rgba, rgba ); + _swrast_texture_fragments( ctx, 0, n, s, t, u, lambda, + (CONST GLchan (*)[4]) rgba, rgba ); } /* Add base and specular colors */ @@ -965,8 +967,8 @@ gl_write_multitexture_span( GLcontext *ctx, */ ASSERT(ctx->Texture._ReallyEnabled); for (i = 0; i < texUnits; i++) - _swrast_texture_fragments( ctx, i, n, s[i], t[i], u[i], - lambda[i], rgbaIn, rgba ); + _swrast_texture_fragments( ctx, i, n, s[i], t[i], u[i], lambda[i], + (CONST GLchan (*)[4]) rgbaIn, rgba ); /* Do the alpha test */ if (_mesa_alpha_test( ctx, n, (const GLchan (*)[4])rgba, mask ) == 0) { @@ -1000,8 +1002,8 @@ gl_write_multitexture_span( GLcontext *ctx, if (! ctx->Color.AlphaEnabled) { ASSERT(ctx->Texture._ReallyEnabled); for (i = 0; i < texUnits; i++) - _swrast_texture_fragments( ctx, i, n, s[i], t[i], u[i], - lambda[i], rgbaIn, rgba ); + _swrast_texture_fragments( ctx, i, n, s[i], t[i], u[i], lambda[i], + (CONST GLchan (*)[4]) rgbaIn, rgba ); } /* Add base and specular colors */ diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index 2a7d3db460e..62439af94c5 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -1,4 +1,4 @@ -/* $Id: s_texture.c,v 1.11 2001/02/17 18:41:01 brianp Exp $ */ +/* $Id: s_texture.c,v 1.12 2001/02/20 16:42:26 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1667,16 +1667,16 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit, #define S_PROD(A,B) ( (GLint)(A) * ((GLint)(B)+1) ) static INLINE void -_mesa_texture_combine(const GLcontext *ctx, - const struct gl_texture_unit *textureUnit, - GLuint n, - GLchan (*primary_rgba)[4], - GLchan (*texel)[4], - GLchan (*rgba)[4]) +texture_combine(const GLcontext *ctx, + const struct gl_texture_unit *textureUnit, + GLuint n, + CONST GLchan (*primary_rgba)[4], + CONST GLchan (*texel)[4], + GLchan (*rgba)[4]) { GLchan ccolor [3][3*MAX_WIDTH][4]; - GLchan (*argRGB [3])[4]; - GLchan (*argA [3])[4]; + const GLchan (*argRGB [3])[4]; + const GLchan (*argA [3])[4]; GLuint i, j; const GLuint RGBshift = textureUnit->CombineScaleShiftRGB; const GLuint Ashift = textureUnit->CombineScaleShiftA; @@ -1692,7 +1692,7 @@ _mesa_texture_combine(const GLcontext *ctx, argA[j] = primary_rgba; break; case GL_PREVIOUS_EXT: - argA[j] = rgba; + argA[j] = (const GLchan (*)[4]) rgba; break; case GL_CONSTANT_EXT: { @@ -1700,7 +1700,7 @@ _mesa_texture_combine(const GLcontext *ctx, UNCLAMPED_FLOAT_TO_CHAN(alpha, textureUnit->EnvColor[3]); for (i = 0; i < n; i++) c[i][ACOMP] = alpha; - argA[j] = ccolor[j]; + argA[j] = (const GLchan (*)[4]) ccolor[j]; } break; default: @@ -1715,7 +1715,7 @@ _mesa_texture_combine(const GLcontext *ctx, argRGB[j] = primary_rgba; break; case GL_PREVIOUS_EXT: - argRGB[j] = rgba; + argRGB[j] = (const GLchan (*)[4]) rgba; break; case GL_CONSTANT_EXT: { @@ -1729,7 +1729,7 @@ _mesa_texture_combine(const GLcontext *ctx, c[i][GCOMP] = green; c[i][BCOMP] = blue; } - argRGB[j] = ccolor[j]; + argRGB[j] = (const GLchan (*)[4]) ccolor[j]; } break; default: @@ -1737,10 +1737,10 @@ _mesa_texture_combine(const GLcontext *ctx, } if (textureUnit->CombineOperandRGB[j] != GL_SRC_COLOR) { - GLchan (*src)[4] = argRGB[j]; + const GLchan (*src)[4] = argRGB[j]; GLchan (*dst)[4] = ccolor[j]; - argRGB[j] = ccolor[j]; + argRGB[j] = (const GLchan (*)[4]) ccolor[j]; if (textureUnit->CombineOperandRGB[j] == GL_ONE_MINUS_SRC_COLOR) { for (i = 0; i < n; i++) { @@ -1750,7 +1750,7 @@ _mesa_texture_combine(const GLcontext *ctx, } } else if (textureUnit->CombineOperandRGB[j] == GL_SRC_ALPHA) { - src = argA[j]; + src = (const GLchan (*)[4]) argA[j]; for (i = 0; i < n; i++) { dst[i][RCOMP] = src[i][ACOMP]; dst[i][GCOMP] = src[i][ACOMP]; @@ -1758,7 +1758,7 @@ _mesa_texture_combine(const GLcontext *ctx, } } else { /* GL_ONE_MINUS_SRC_ALPHA */ - src = argA[j]; + src = (const GLchan (*)[4]) argA[j]; for (i = 0; i < n; i++) { dst[i][RCOMP] = CHAN_MAX - src[i][ACOMP]; dst[i][GCOMP] = CHAN_MAX - src[i][ACOMP]; @@ -1768,9 +1768,9 @@ _mesa_texture_combine(const GLcontext *ctx, } if (textureUnit->CombineOperandA[j] == GL_ONE_MINUS_SRC_ALPHA) { - GLchan (*src)[4] = argA[j]; + const GLchan (*src)[4] = argA[j]; GLchan (*dst)[4] = ccolor[j]; - argA[j] = ccolor[j]; + argA[j] = (const GLchan (*)[4]) ccolor[j]; for (i = 0; i < n; i++) { dst[i][ACOMP] = CHAN_MAX - src[i][ACOMP]; } @@ -1994,7 +1994,7 @@ _mesa_texture_combine(const GLcontext *ctx, * Input: textureUnit - pointer to texture unit to apply * format - base internal texture format * n - number of fragments - * primary_rgba - primary colors (may be rgba for single texture) + * primary_rgba - primary colors (may alias rgba for single texture) * texels - array of texel colors * InOut: rgba - incoming fragment colors modified by texel colors * according to the texture environment mode. @@ -2003,7 +2003,7 @@ static void apply_texture( const GLcontext *ctx, const struct gl_texture_unit *texUnit, GLuint n, - GLchan primary_rgba[][4], GLchan texel[][4], + CONST GLchan primary_rgba[][4], CONST GLchan texel[][4], GLchan rgba[][4] ) { GLint baseLevel; @@ -2019,7 +2019,7 @@ apply_texture( const GLcontext *ctx, format = texUnit->_Current->Image[baseLevel]->Format; - if (format==GL_COLOR_INDEX) { + if (format==GL_COLOR_INDEX || format==GL_DEPTH_COMPONENT) { format = GL_RGBA; /* XXXX a hack! */ } @@ -2328,50 +2328,8 @@ apply_texture( const GLcontext *ctx, } break; - case GL_COMBINE_EXT: /* GL_EXT_combine_ext; we modify texel array */ - switch (format) { - case GL_ALPHA: - for (i=0;i<n;i++) - texel[i][RCOMP] = texel[i][GCOMP] = texel[i][BCOMP] = 0; - break; - case GL_LUMINANCE: - for (i=0;i<n;i++) { - /* Cv = Lt */ - GLchan Lt = texel[i][RCOMP]; - texel[i][GCOMP] = texel[i][BCOMP] = Lt; - /* Av = 1 */ - texel[i][ACOMP] = CHAN_MAX; - } - break; - case GL_LUMINANCE_ALPHA: - for (i=0;i<n;i++) { - GLchan Lt = texel[i][RCOMP]; - /* Cv = Lt */ - texel[i][GCOMP] = texel[i][BCOMP] = Lt; - } - break; - case GL_INTENSITY: - for (i=0;i<n;i++) { - /* Cv = It */ - GLchan It = texel[i][RCOMP]; - texel[i][GCOMP] = texel[i][BCOMP] = It; - /* Av = It */ - texel[i][ACOMP] = It; - } - break; - case GL_RGB: - for (i=0;i<n;i++) { - /* Av = 1 */ - texel[i][ACOMP] = CHAN_MAX; - } - break; - case GL_RGBA: /* do nothing. */ - break; - default: - gl_problem(ctx, "Bad format in apply_texture (GL_COMBINE_EXT)"); - return; - } - _mesa_texture_combine(ctx, texUnit, n, primary_rgba, texel, rgba); + case GL_COMBINE_EXT: + texture_combine(ctx, texUnit, n, primary_rgba, texel, rgba); break; default: @@ -2383,13 +2341,73 @@ apply_texture( const GLcontext *ctx, /* + * Apply a shadow/depth texture to the array of colors. + * Input: ctx - context + * texUnit - the texture unit + * n - number of colors + * r - array [n] of texture R coordinates + * In/Out: rgba - array [n] of colors. + */ +static void +sample_depth_texture(const GLcontext *ctx, + const struct gl_texture_unit *texUnit, + GLuint n, + const GLfloat s[], const GLfloat t[], const GLfloat r[], + GLchan texel[][4]) +{ + const struct gl_texture_object *texObj = texUnit->_Current; + const struct gl_texture_image *texImage = texObj->Image[0]; /* XXX hack */ + const GLchan ambient = texObj->ShadowAmbient; + GLboolean lequal, gequal; + GLuint i; + + if (texObj->CompareOperator == GL_TEXTURE_LEQUAL_R_SGIX) { + lequal = GL_TRUE; + gequal = GL_FALSE; + } + else { + lequal = GL_FALSE; + gequal = GL_TRUE; + } + + assert(texObj->Dimensions == 2); + assert(texImage->Format == GL_DEPTH_COMPONENT); + + for (i = 0; i < n; i++) { + const GLfloat *src; + GLfloat depthSample; + GLint col, row; + /* XXX this is a hack - implement proper sampling */ + COMPUTE_NEAREST_TEXEL_LOCATION(texObj->WrapS, s[i], texImage->Width, col); + COMPUTE_NEAREST_TEXEL_LOCATION(texObj->WrapT, t[i], texImage->Height,row); + src = (const GLfloat *) texImage->Data + row * texImage->Width + col; + depthSample = *src; + if ((depthSample <= r[i] && lequal) || + (depthSample >= r[i] && gequal)) { + texel[i][RCOMP] = ambient; + texel[i][GCOMP] = ambient; + texel[i][BCOMP] = ambient; + texel[i][ACOMP] = CHAN_MAX; + } + else { + texel[i][RCOMP] = CHAN_MAX; + texel[i][GCOMP] = CHAN_MAX; + texel[i][BCOMP] = CHAN_MAX; + texel[i][ACOMP] = CHAN_MAX; + } + } +} + + + +/* * Apply a unit of texture mapping to the incoming fragments. */ void _swrast_texture_fragments( GLcontext *ctx, GLuint texUnit, GLuint n, const GLfloat s[], const GLfloat t[], const GLfloat r[], GLfloat lambda[], - GLchan primary_rgba[][4], GLchan rgba[][4] ) + CONST GLchan primary_rgba[][4], GLchan rgba[][4] ) { const GLuint mask = TEXTURE0_ANY << (texUnit * 4); @@ -2410,8 +2428,8 @@ _swrast_texture_fragments( GLcontext *ctx, GLuint texUnit, GLuint n, if (textureUnit->_Current->MinLod != -1000.0 || textureUnit->_Current->MaxLod != 1000.0) { /* apply LOD clamping to lambda */ - GLfloat min = textureUnit->_Current->MinLod; - GLfloat max = textureUnit->_Current->MaxLod; + const GLfloat min = textureUnit->_Current->MinLod; + const GLfloat max = textureUnit->_Current->MaxLod; GLuint i; for (i=0;i<n;i++) { GLfloat l = lambda[i]; @@ -2420,12 +2438,19 @@ _swrast_texture_fragments( GLcontext *ctx, GLuint texUnit, GLuint n, } /* Sample the texture. */ - SWRAST_CONTEXT(ctx)->TextureSample[texUnit]( ctx, texUnit, - textureUnit->_Current, - n, s, t, r, - lambda, texel ); - - apply_texture( ctx, textureUnit, n, primary_rgba, texel, rgba ); + if (textureUnit->_Current->CompareFlag) { + /* depth texture */ + sample_depth_texture(ctx, textureUnit, n, s, t, r, texel); + } + else { + /* color texture */ + SWRAST_CONTEXT(ctx)->TextureSample[texUnit]( ctx, texUnit, + textureUnit->_Current, + n, s, t, r, + lambda, texel ); + } + apply_texture( ctx, textureUnit, n, primary_rgba, + (const GLchan (*)[4]) texel, rgba ); } } } diff --git a/src/mesa/swrast/s_texture.h b/src/mesa/swrast/s_texture.h index 9a64928b5d4..821e8199d5b 100644 --- a/src/mesa/swrast/s_texture.h +++ b/src/mesa/swrast/s_texture.h @@ -1,10 +1,10 @@ -/* $Id: s_texture.h,v 1.4 2001/01/05 21:28:31 brianp Exp $ */ +/* $Id: s_texture.h,v 1.5 2001/02/20 16:42:26 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 3.5 * - * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -43,7 +43,7 @@ extern void _swrast_texture_fragments( GLcontext *ctx, GLuint texSet, GLuint n, const GLfloat s[], const GLfloat t[], const GLfloat r[], GLfloat lambda[], - GLchan primary_rgba[][4], GLchan rgba[][4] ); + CONST GLchan primary_rgba[][4], GLchan rgba[][4] ); #endif |