Added some const keywords in the s/w texturing code.
-/* $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
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;
-/* $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
{ 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) }
};
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");
}
-/* $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
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];
GLboolean SGIX_depth_texture;
GLboolean SGIX_pixel_texture;
GLboolean SGIX_shadow;
+ GLboolean SGIX_shadow_ambient;
GLboolean _3DFX_texture_compression_FXT1;
};
-/* $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
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);
-/* $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
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 */
-/* $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
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)");
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;
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)" );
}
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)" );
}
-/* $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_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);
}
}
_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);
}
}
-/* $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_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);
}
}
}
-/* $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
/* 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) {
/* 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 */
*/
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) {
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 */
-/* $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
#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;
argA[j] = primary_rgba;
break;
case GL_PREVIOUS_EXT:
- argA[j] = rgba;
+ argA[j] = (const GLchan (*)[4]) rgba;
break;
case GL_CONSTANT_EXT:
{
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:
argRGB[j] = primary_rgba;
break;
case GL_PREVIOUS_EXT:
- argRGB[j] = rgba;
+ argRGB[j] = (const GLchan (*)[4]) rgba;
break;
case GL_CONSTANT_EXT:
{
c[i][GCOMP] = green;
c[i][BCOMP] = blue;
}
- argRGB[j] = ccolor[j];
+ argRGB[j] = (const GLchan (*)[4]) ccolor[j];
}
break;
default:
}
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++) {
}
}
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];
}
}
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];
}
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];
}
* 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.
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;
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! */
}
}
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:
+/*
+ * 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.
*/
_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);
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];
}
/* 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 );
}
}
}
-/* $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"),
_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