Implemented GL_SGIX_shadow and GL_SGIX_shadow_texture.

Added some const keywords in the s/w texturing code.
This commit is contained in:
Brian Paul
2001-02-20 16:42:25 +00:00
parent 0c75c4c417
commit c499ce31ba
11 changed files with 169 additions and 98 deletions

View File

@@ -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 * Mesa 3-D graphics library
@@ -101,6 +101,9 @@ copy_texobj_state( struct gl_texture_object *dest,
dest->MaxLod = src->MaxLod; dest->MaxLod = src->MaxLod;
dest->BaseLevel = src->BaseLevel; dest->BaseLevel = src->BaseLevel;
dest->MaxLevel = src->MaxLevel; dest->MaxLevel = src->MaxLevel;
dest->CompareFlag = src->CompareFlag;
dest->CompareOperator = src->CompareOperator;
dest->ShadowAmbient = src->ShadowAmbient;
dest->_MaxLevel = src->_MaxLevel; dest->_MaxLevel = src->_MaxLevel;
dest->_MaxLambda = src->_MaxLambda; dest->_MaxLambda = src->_MaxLambda;
dest->Palette = src->Palette; dest->Palette = src->Palette;

View File

@@ -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 * Mesa 3-D graphics library
@@ -105,6 +105,7 @@ static struct {
{ ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
{ OFF, "GL_SGIX_depth_texture", F(SGIX_depth_texture) }, { OFF, "GL_SGIX_depth_texture", F(SGIX_depth_texture) },
{ OFF, "GL_SGIX_shadow", F(SGIX_shadow) }, { 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) }, { ON, "GL_SGIX_pixel_texture", F(SGIX_pixel_texture) },
{ OFF, "GL_3DFX_texture_compression_FXT1", F(_3DFX_texture_compression_FXT1) } { 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_NV_blend_square");
gl_extensions_enable(ctx, "GL_MESA_sprite_point"); gl_extensions_enable(ctx, "GL_MESA_sprite_point");
gl_extensions_enable(ctx, "GL_SGIX_depth_texture"); 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");
} }

View File

@@ -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 * Mesa 3-D graphics library
@@ -834,6 +834,7 @@ struct gl_texture_object {
GLint MaxLevel; /* max mipmap level, OpenGL 1.2 */ GLint MaxLevel; /* max mipmap level, OpenGL 1.2 */
GLboolean CompareFlag; /* GL_SGIX_shadow */ GLboolean CompareFlag; /* GL_SGIX_shadow */
GLenum CompareOperator; /* GL_SGIX_shadow */ GLenum CompareOperator; /* GL_SGIX_shadow */
GLchan ShadowAmbient; /* GL_SGIX_shadow_ambient */
GLint _MaxLevel; /* actual max mipmap level (q in the spec) */ GLint _MaxLevel; /* actual max mipmap level (q in the spec) */
GLfloat _MaxLambda; /* = _MaxLevel - BaseLevel (q - b in spec) */ GLfloat _MaxLambda; /* = _MaxLevel - BaseLevel (q - b in spec) */
struct gl_texture_image *Image[MAX_TEXTURE_LEVELS]; struct gl_texture_image *Image[MAX_TEXTURE_LEVELS];
@@ -1230,6 +1231,7 @@ struct gl_extensions {
GLboolean SGIX_depth_texture; GLboolean SGIX_depth_texture;
GLboolean SGIX_pixel_texture; GLboolean SGIX_pixel_texture;
GLboolean SGIX_shadow; GLboolean SGIX_shadow;
GLboolean SGIX_shadow_ambient;
GLboolean _3DFX_texture_compression_FXT1; GLboolean _3DFX_texture_compression_FXT1;
}; };

View File

@@ -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 * Mesa 3-D graphics library
@@ -993,6 +993,11 @@ void gl_update_state( GLcontext *ctx )
ASSERT(ctx->Driver.TexSubImage1D); ASSERT(ctx->Driver.TexSubImage1D);
ASSERT(ctx->Driver.TexSubImage2D); ASSERT(ctx->Driver.TexSubImage2D);
ASSERT(ctx->Driver.TexSubImage3D); 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) { if (ctx->Extensions.ARB_texture_compression) {
ASSERT(ctx->Driver.CompressedTexImage1D); ASSERT(ctx->Driver.CompressedTexImage1D);
ASSERT(ctx->Driver.CompressedTexImage2D); ASSERT(ctx->Driver.CompressedTexImage2D);

View File

@@ -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 * Mesa 3-D graphics library
@@ -81,6 +81,7 @@ _mesa_alloc_texture_object( struct gl_shared_state *shared,
obj->MaxLevel = 1000; obj->MaxLevel = 1000;
obj->CompareFlag = GL_FALSE; obj->CompareFlag = GL_FALSE;
obj->CompareOperator = GL_TEXTURE_LEQUAL_R_SGIX; obj->CompareOperator = GL_TEXTURE_LEQUAL_R_SGIX;
obj->ShadowAmbient = 0;
_mesa_init_colortable(&obj->Palette); _mesa_init_colortable(&obj->Palette);
/* insert into linked list */ /* insert into linked list */

View File

@@ -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 * Mesa 3-D graphics library
@@ -784,7 +784,7 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
GLenum op = (GLenum) params[0]; GLenum op = (GLenum) params[0];
if (op == GL_TEXTURE_LEQUAL_R_SGIX || if (op == GL_TEXTURE_LEQUAL_R_SGIX ||
op == GL_TEXTURE_GEQUAL_R_SGIX) { op == GL_TEXTURE_GEQUAL_R_SGIX) {
texObj->CompareFlag = (GLenum) op; texObj->CompareOperator = op;
} }
else { else {
gl_error(ctx, GL_INVALID_ENUM, "glTexParameter(param)"); gl_error(ctx, GL_INVALID_ENUM, "glTexParameter(param)");
@@ -795,6 +795,15 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
return; return;
} }
break; 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: default:
gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(pname)" ); gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(pname)" );
return; return;
@@ -1064,6 +1073,15 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
return; return;
} }
break; 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: default:
gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" ); gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" );
} }
@@ -1156,6 +1174,16 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
return; return;
} }
break; 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: default:
gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)" ); gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)" );
} }

View File

@@ -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 * 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, _mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba,
s, t, r, q); s, t, r, q);
_swrast_texture_fragments(ctx, unit, width, s, t, r, NULL, _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, _mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba,
s, t, r, q); s, t, r, q);
_swrast_texture_fragments(ctx, unit, width, s, t, r, NULL, _swrast_texture_fragments(ctx, unit, width, s, t, r, NULL,
primary_rgba, rgba); (CONST GLchan (*)[4]) primary_rgba,
rgba);
} }
} }

View File

@@ -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 * 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, _mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba,
s, t, r, q); s, t, r, q);
_swrast_texture_fragments(ctx, unit, width, s, t, r, NULL, _swrast_texture_fragments(ctx, unit, width, s, t, r, NULL,
primary_rgba, rgba); (CONST GLchan (*)[4]) primary_rgba,
rgba);
} }
} }
} }

View File

@@ -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 * 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 /* Texturing without alpha is done after depth-testing which
gives a potential speed-up. */ gives a potential speed-up. */
ASSERT(ctx->Texture._ReallyEnabled); 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 */ /* Do the alpha test */
if (_mesa_alpha_test( ctx, n, (const GLchan (*)[4]) rgba, mask ) == 0) { 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 */ /* Texture without alpha test */
if (! ctx->Color.AlphaEnabled) { if (! ctx->Color.AlphaEnabled) {
ASSERT(ctx->Texture._ReallyEnabled); 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 */ /* Add base and specular colors */
@@ -965,8 +967,8 @@ gl_write_multitexture_span( GLcontext *ctx,
*/ */
ASSERT(ctx->Texture._ReallyEnabled); ASSERT(ctx->Texture._ReallyEnabled);
for (i = 0; i < texUnits; i++) for (i = 0; i < texUnits; i++)
_swrast_texture_fragments( ctx, i, n, s[i], t[i], u[i], _swrast_texture_fragments( ctx, i, n, s[i], t[i], u[i], lambda[i],
lambda[i], rgbaIn, rgba ); (CONST GLchan (*)[4]) rgbaIn, rgba );
/* Do the alpha test */ /* Do the alpha test */
if (_mesa_alpha_test( ctx, n, (const GLchan (*)[4])rgba, mask ) == 0) { 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) { if (! ctx->Color.AlphaEnabled) {
ASSERT(ctx->Texture._ReallyEnabled); ASSERT(ctx->Texture._ReallyEnabled);
for (i = 0; i < texUnits; i++) for (i = 0; i < texUnits; i++)
_swrast_texture_fragments( ctx, i, n, s[i], t[i], u[i], _swrast_texture_fragments( ctx, i, n, s[i], t[i], u[i], lambda[i],
lambda[i], rgbaIn, rgba ); (CONST GLchan (*)[4]) rgbaIn, rgba );
} }
/* Add base and specular colors */ /* Add base and specular colors */

View File

@@ -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 * 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) ) #define S_PROD(A,B) ( (GLint)(A) * ((GLint)(B)+1) )
static INLINE void static INLINE void
_mesa_texture_combine(const GLcontext *ctx, texture_combine(const GLcontext *ctx,
const struct gl_texture_unit *textureUnit, const struct gl_texture_unit *textureUnit,
GLuint n, GLuint n,
GLchan (*primary_rgba)[4], CONST GLchan (*primary_rgba)[4],
GLchan (*texel)[4], CONST GLchan (*texel)[4],
GLchan (*rgba)[4]) GLchan (*rgba)[4])
{ {
GLchan ccolor [3][3*MAX_WIDTH][4]; GLchan ccolor [3][3*MAX_WIDTH][4];
GLchan (*argRGB [3])[4]; const GLchan (*argRGB [3])[4];
GLchan (*argA [3])[4]; const GLchan (*argA [3])[4];
GLuint i, j; GLuint i, j;
const GLuint RGBshift = textureUnit->CombineScaleShiftRGB; const GLuint RGBshift = textureUnit->CombineScaleShiftRGB;
const GLuint Ashift = textureUnit->CombineScaleShiftA; const GLuint Ashift = textureUnit->CombineScaleShiftA;
@@ -1692,7 +1692,7 @@ _mesa_texture_combine(const GLcontext *ctx,
argA[j] = primary_rgba; argA[j] = primary_rgba;
break; break;
case GL_PREVIOUS_EXT: case GL_PREVIOUS_EXT:
argA[j] = rgba; argA[j] = (const GLchan (*)[4]) rgba;
break; break;
case GL_CONSTANT_EXT: case GL_CONSTANT_EXT:
{ {
@@ -1700,7 +1700,7 @@ _mesa_texture_combine(const GLcontext *ctx,
UNCLAMPED_FLOAT_TO_CHAN(alpha, textureUnit->EnvColor[3]); UNCLAMPED_FLOAT_TO_CHAN(alpha, textureUnit->EnvColor[3]);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
c[i][ACOMP] = alpha; c[i][ACOMP] = alpha;
argA[j] = ccolor[j]; argA[j] = (const GLchan (*)[4]) ccolor[j];
} }
break; break;
default: default:
@@ -1715,7 +1715,7 @@ _mesa_texture_combine(const GLcontext *ctx,
argRGB[j] = primary_rgba; argRGB[j] = primary_rgba;
break; break;
case GL_PREVIOUS_EXT: case GL_PREVIOUS_EXT:
argRGB[j] = rgba; argRGB[j] = (const GLchan (*)[4]) rgba;
break; break;
case GL_CONSTANT_EXT: case GL_CONSTANT_EXT:
{ {
@@ -1729,7 +1729,7 @@ _mesa_texture_combine(const GLcontext *ctx,
c[i][GCOMP] = green; c[i][GCOMP] = green;
c[i][BCOMP] = blue; c[i][BCOMP] = blue;
} }
argRGB[j] = ccolor[j]; argRGB[j] = (const GLchan (*)[4]) ccolor[j];
} }
break; break;
default: default:
@@ -1737,10 +1737,10 @@ _mesa_texture_combine(const GLcontext *ctx,
} }
if (textureUnit->CombineOperandRGB[j] != GL_SRC_COLOR) { if (textureUnit->CombineOperandRGB[j] != GL_SRC_COLOR) {
GLchan (*src)[4] = argRGB[j]; const GLchan (*src)[4] = argRGB[j];
GLchan (*dst)[4] = ccolor[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) { if (textureUnit->CombineOperandRGB[j] == GL_ONE_MINUS_SRC_COLOR) {
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@@ -1750,7 +1750,7 @@ _mesa_texture_combine(const GLcontext *ctx,
} }
} }
else if (textureUnit->CombineOperandRGB[j] == GL_SRC_ALPHA) { else if (textureUnit->CombineOperandRGB[j] == GL_SRC_ALPHA) {
src = argA[j]; src = (const GLchan (*)[4]) argA[j];
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
dst[i][RCOMP] = src[i][ACOMP]; dst[i][RCOMP] = src[i][ACOMP];
dst[i][GCOMP] = 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 */ else { /* GL_ONE_MINUS_SRC_ALPHA */
src = argA[j]; src = (const GLchan (*)[4]) argA[j];
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
dst[i][RCOMP] = CHAN_MAX - src[i][ACOMP]; dst[i][RCOMP] = CHAN_MAX - src[i][ACOMP];
dst[i][GCOMP] = 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) { 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]; GLchan (*dst)[4] = ccolor[j];
argA[j] = ccolor[j]; argA[j] = (const GLchan (*)[4]) ccolor[j];
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
dst[i][ACOMP] = CHAN_MAX - src[i][ACOMP]; 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 * Input: textureUnit - pointer to texture unit to apply
* format - base internal texture format * format - base internal texture format
* n - number of fragments * 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 * texels - array of texel colors
* InOut: rgba - incoming fragment colors modified by texel colors * InOut: rgba - incoming fragment colors modified by texel colors
* according to the texture environment mode. * according to the texture environment mode.
@@ -2003,7 +2003,7 @@ static void
apply_texture( const GLcontext *ctx, apply_texture( const GLcontext *ctx,
const struct gl_texture_unit *texUnit, const struct gl_texture_unit *texUnit,
GLuint n, GLuint n,
GLchan primary_rgba[][4], GLchan texel[][4], CONST GLchan primary_rgba[][4], CONST GLchan texel[][4],
GLchan rgba[][4] ) GLchan rgba[][4] )
{ {
GLint baseLevel; GLint baseLevel;
@@ -2019,7 +2019,7 @@ apply_texture( const GLcontext *ctx,
format = texUnit->_Current->Image[baseLevel]->Format; 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! */ format = GL_RGBA; /* XXXX a hack! */
} }
@@ -2328,50 +2328,8 @@ apply_texture( const GLcontext *ctx,
} }
break; break;
case GL_COMBINE_EXT: /* GL_EXT_combine_ext; we modify texel array */ case GL_COMBINE_EXT:
switch (format) { texture_combine(ctx, texUnit, n, primary_rgba, texel, rgba);
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);
break; break;
default: default:
@@ -2382,6 +2340,66 @@ 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. * Apply a unit of texture mapping to the incoming fragments.
*/ */
@@ -2389,7 +2407,7 @@ void
_swrast_texture_fragments( GLcontext *ctx, GLuint texUnit, GLuint n, _swrast_texture_fragments( GLcontext *ctx, GLuint texUnit, GLuint n,
const GLfloat s[], const GLfloat t[], const GLfloat s[], const GLfloat t[],
const GLfloat r[], GLfloat lambda[], 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); 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 if (textureUnit->_Current->MinLod != -1000.0
|| textureUnit->_Current->MaxLod != 1000.0) { || textureUnit->_Current->MaxLod != 1000.0) {
/* apply LOD clamping to lambda */ /* apply LOD clamping to lambda */
GLfloat min = textureUnit->_Current->MinLod; const GLfloat min = textureUnit->_Current->MinLod;
GLfloat max = textureUnit->_Current->MaxLod; const GLfloat max = textureUnit->_Current->MaxLod;
GLuint i; GLuint i;
for (i=0;i<n;i++) { for (i=0;i<n;i++) {
GLfloat l = lambda[i]; GLfloat l = lambda[i];
@@ -2420,12 +2438,19 @@ _swrast_texture_fragments( GLcontext *ctx, GLuint texUnit, GLuint n,
} }
/* Sample the texture. */ /* Sample the texture. */
SWRAST_CONTEXT(ctx)->TextureSample[texUnit]( ctx, texUnit, if (textureUnit->_Current->CompareFlag) {
textureUnit->_Current, /* depth texture */
n, s, t, r, sample_depth_texture(ctx, textureUnit, n, s, t, r, texel);
lambda, texel ); }
else {
apply_texture( ctx, textureUnit, n, primary_rgba, texel, rgba ); /* 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 );
} }
} }
} }

View File

@@ -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 * Mesa 3-D graphics library
* Version: 3.5 * 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * 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, _swrast_texture_fragments( GLcontext *ctx, GLuint texSet, GLuint n,
const GLfloat s[], const GLfloat t[], const GLfloat s[], const GLfloat t[],
const GLfloat r[], GLfloat lambda[], const GLfloat r[], GLfloat lambda[],
GLchan primary_rgba[][4], GLchan rgba[][4] ); CONST GLchan primary_rgba[][4], GLchan rgba[][4] );
#endif #endif