diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/glide/fxddtex.c | 55 | ||||
-rw-r--r-- | src/mesa/main/context.c | 12 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 4 | ||||
-rw-r--r-- | src/mesa/main/histogram.c | 12 | ||||
-rw-r--r-- | src/mesa/main/image.c | 42 | ||||
-rw-r--r-- | src/mesa/main/image.h | 7 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 70 | ||||
-rw-r--r-- | src/mesa/main/teximage.c | 31 | ||||
-rw-r--r-- | src/mesa/main/texobj.c | 4 | ||||
-rw-r--r-- | src/mesa/main/texstate.c | 63 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 381 | ||||
-rw-r--r-- | src/mesa/swrast/s_drawpix.c | 16 | ||||
-rw-r--r-- | src/mesa/swrast/s_texture.c | 139 |
13 files changed, 470 insertions, 366 deletions
diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c index a2107cec50c..1ded0f4cca5 100644 --- a/src/mesa/drivers/glide/fxddtex.c +++ b/src/mesa/drivers/glide/fxddtex.c @@ -825,11 +825,10 @@ static GLboolean fxIsTexSupported(GLenum target, GLint internalFormat, */ static void -fetch_intensity8(GLcontext *ctx, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan rgba[4]) +fetch_intensity8(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texelOut) { + GLchan *rgba = (GLchan *) texelOut; const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); const GLubyte *texel; @@ -845,11 +844,10 @@ fetch_intensity8(GLcontext *ctx, static void -fetch_luminance8(GLcontext *ctx, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan rgba[4]) +fetch_luminance8(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texelOut) { + GLchan *rgba = (GLchan *) texelOut; const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); const GLubyte *texel; @@ -865,11 +863,10 @@ fetch_luminance8(GLcontext *ctx, static void -fetch_alpha8(GLcontext *ctx, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan rgba[4]) +fetch_alpha8(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texelOut) { + GLchan *rgba = (GLchan *) texelOut; const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); const GLubyte *texel; @@ -887,21 +884,18 @@ fetch_alpha8(GLcontext *ctx, static void -fetch_index8(GLcontext *ctx, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan rgba[4]) +fetch_index8(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texelOut) { /* XXX todo */ } static void -fetch_luminance8_alpha8(GLcontext *ctx, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan rgba[4]) +fetch_luminance8_alpha8(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texelOut) { + GLchan *rgba = (GLchan *) texelOut; const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); const GLubyte *texel; @@ -917,11 +911,10 @@ fetch_luminance8_alpha8(GLcontext *ctx, static void -fetch_r5g6b5(GLcontext *ctx, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan rgba[4]) +fetch_r5g6b5(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texelOut) { + GLchan *rgba = (GLchan *) texelOut; const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); const GLushort *texel; @@ -937,11 +930,10 @@ fetch_r5g6b5(GLcontext *ctx, static void -fetch_r4g4b4a4(GLcontext *ctx, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan rgba[4]) +fetch_r4g4b4a4(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texelOut) { + GLchan *rgba = (GLchan *) texelOut; const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); const GLushort *texel; @@ -957,11 +949,10 @@ fetch_r4g4b4a4(GLcontext *ctx, static void -fetch_r5g5b5a1(GLcontext *ctx, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan rgba[4]) +fetch_r5g5b5a1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLvoid *texelOut) { + GLchan *rgba = (GLchan *) texelOut; const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage); const GLushort *texel; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index c044a6adde4..49b4a01b8a0 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,4 +1,4 @@ -/* $Id: context.c,v 1.120 2001/02/06 21:42:48 brianp Exp $ */ +/* $Id: context.c,v 1.121 2001/02/17 18:41:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -916,11 +916,11 @@ init_attrib_groups( GLcontext *ctx ) ctx->Histogram.Width = 0; ctx->Histogram.Format = GL_RGBA; ctx->Histogram.Sink = GL_FALSE; - ctx->Histogram.RedSize = 0xffffffff; - ctx->Histogram.GreenSize = 0xffffffff; - ctx->Histogram.BlueSize = 0xffffffff; - ctx->Histogram.AlphaSize = 0xffffffff; - ctx->Histogram.LuminanceSize = 0xffffffff; + ctx->Histogram.RedSize = 0; + ctx->Histogram.GreenSize = 0; + ctx->Histogram.BlueSize = 0; + ctx->Histogram.AlphaSize = 0; + ctx->Histogram.LuminanceSize = 0; for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { ctx->Histogram.Count[i][0] = 0; ctx->Histogram.Count[i][1] = 0; diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 7c6dc8b72a9..c68d751d322 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -1,4 +1,4 @@ -/* $Id: extensions.c,v 1.46 2001/02/17 00:15:39 brianp Exp $ */ +/* $Id: extensions.c,v 1.47 2001/02/17 18:41:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -104,6 +104,7 @@ static struct { { ON, "GL_SGIS_pixel_texture", F(SGIS_pixel_texture) }, { 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) }, { ON, "GL_SGIX_pixel_texture", F(SGIX_pixel_texture) }, { OFF, "GL_3DFX_texture_compression_FXT1", F(_3DFX_texture_compression_FXT1) } }; @@ -126,6 +127,7 @@ _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 */ } diff --git a/src/mesa/main/histogram.c b/src/mesa/main/histogram.c index 7a3f7f47731..dddaac39350 100644 --- a/src/mesa/main/histogram.c +++ b/src/mesa/main/histogram.c @@ -1,4 +1,4 @@ -/* $Id: histogram.c,v 1.6 2001/01/30 17:46:34 brianp Exp $ */ +/* $Id: histogram.c,v 1.7 2001/02/17 18:41:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -944,11 +944,11 @@ _mesa_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean s ctx->Histogram.Width = width; ctx->Histogram.Format = internalFormat; ctx->Histogram.Sink = sink; - ctx->Histogram.RedSize = 0xffffffff; - ctx->Histogram.GreenSize = 0xffffffff; - ctx->Histogram.BlueSize = 0xffffffff; - ctx->Histogram.AlphaSize = 0xffffffff; - ctx->Histogram.LuminanceSize = 0xffffffff; + ctx->Histogram.RedSize = 8 * sizeof(GLuint); + ctx->Histogram.GreenSize = 8 * sizeof(GLuint); + ctx->Histogram.BlueSize = 8 * sizeof(GLuint); + ctx->Histogram.AlphaSize = 8 * sizeof(GLuint); + ctx->Histogram.LuminanceSize = 8 * sizeof(GLuint); } ctx->NewState |= _NEW_PIXEL; diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 46254239f67..1ae4925742a 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.55 2001/02/16 23:29:14 brianp Exp $ */ +/* $Id: image.c,v 1.56 2001/02/17 18:41:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -3507,22 +3507,17 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, void -_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest, +_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest, GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLuint transferOps ) + const struct gl_pixelstore_attrib *srcPacking ) { - GLfloat *depth = MALLOC(n * sizeof(GLfloat)); - if (!depth) - return; - switch (srcType) { case GL_BYTE: { GLuint i; const GLubyte *src = (const GLubyte *) source; for (i = 0; i < n; i++) { - depth[i] = BYTE_TO_FLOAT(src[i]); + dest[i] = BYTE_TO_FLOAT(src[i]); } } break; @@ -3531,7 +3526,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest, GLuint i; const GLubyte *src = (const GLubyte *) source; for (i = 0; i < n; i++) { - depth[i] = UBYTE_TO_FLOAT(src[i]); + dest[i] = UBYTE_TO_FLOAT(src[i]); } } break; @@ -3540,7 +3535,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest, GLuint i; const GLshort *src = (const GLshort *) source; for (i = 0; i < n; i++) { - depth[i] = SHORT_TO_FLOAT(src[i]); + dest[i] = SHORT_TO_FLOAT(src[i]); } } break; @@ -3549,7 +3544,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest, GLuint i; const GLushort *src = (const GLushort *) source; for (i = 0; i < n; i++) { - depth[i] = USHORT_TO_FLOAT(src[i]); + dest[i] = USHORT_TO_FLOAT(src[i]); } } break; @@ -3558,7 +3553,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest, GLuint i; const GLint *src = (const GLint *) source; for (i = 0; i < n; i++) { - depth[i] = INT_TO_FLOAT(src[i]); + dest[i] = INT_TO_FLOAT(src[i]); } } break; @@ -3567,38 +3562,27 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest, GLuint i; const GLuint *src = (const GLuint *) source; for (i = 0; i < n; i++) { - depth[i] = UINT_TO_FLOAT(src[i]); + dest[i] = UINT_TO_FLOAT(src[i]); } } break; case GL_FLOAT: - MEMCPY(depth, source, n * sizeof(GLfloat)); + MEMCPY(dest, source, n * sizeof(GLfloat)); break; default: gl_problem(NULL, "bad type in _mesa_unpack_depth_span()"); - FREE(depth); return; } - /* apply depth scale and bias */ + /* apply depth scale and bias and clamp to [0,1] */ if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) { GLuint i; for (i = 0; i < n; i++) { - depth[i] = depth[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias; + GLfloat d = dest[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias; + dest[i] = CLAMP(d, 0.0F, 1.0F); } } - - /* clamp depth values to [0,1] and convert from floats to integers */ - { - const GLfloat zs = ctx->DepthMaxF; - GLuint i; - for (i = 0; i < n; i++) { - dest[i] = (GLdepth) (CLAMP(depth[i], 0.0F, 1.0F) * zs); - } - } - - FREE(depth); } diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index b994ca27cf3..7ad693e7e22 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -1,4 +1,4 @@ -/* $Id: image.h,v 1.15 2001/02/16 23:29:14 brianp Exp $ */ +/* $Id: image.h,v 1.16 2001/02/17 18:41:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -151,10 +151,9 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, extern void -_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest, +_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest, GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLuint transferOps ); + const struct gl_pixelstore_attrib *srcPacking ); extern void _mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 59cd836c8ac..b890fa0dbd0 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.19 2001/02/17 00:15:39 brianp Exp $ */ +/* $Id: mtypes.h,v 1.20 2001/02/17 18:41:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -132,17 +132,17 @@ typedef struct gl_frame_buffer GLframebuffer; /* Data structure for color tables */ struct gl_color_table { - GLvoid *Table; - GLboolean FloatTable; /* entries stored as floats? (or GLchan type) */ - GLuint Size; /* number of entries (rows) in table */ - GLenum Format; + GLenum Format; /* GL_ALPHA, GL_RGB, GL_RGB, etc */ GLenum IntFormat; - GLint RedSize; - GLint GreenSize; - GLint BlueSize; - GLint AlphaSize; - GLint LuminanceSize; - GLint IntensitySize; + GLuint Size; /* number of entries (rows) in table */ + GLvoid *Table; /* either GLfloat * or GLchan * */ + GLboolean FloatTable; /* are entries stored as floats? */ + GLubyte RedSize; + GLubyte GreenSize; + GLubyte BlueSize; + GLubyte AlphaSize; + GLubyte LuminanceSize; + GLubyte IntensitySize; }; @@ -218,8 +218,8 @@ struct gl_light { GLfloat _MatAmbient[2][3]; /* material ambient * light ambient */ GLfloat _MatDiffuse[2][3]; /* material diffuse * light diffuse */ GLfloat _MatSpecular[2][3]; /* material spec * light specular */ - GLfloat _dli; /* CI diffuse light intensity */ - GLfloat _sli; /* CI specular light intensity */ + GLfloat _dli; /* CI diffuse light intensity */ + GLfloat _sli; /* CI specular light intensity */ }; @@ -446,15 +446,15 @@ struct gl_hint_attrib { struct gl_histogram_attrib { - GLuint Width; - GLint Format; - GLboolean Sink; - GLuint RedSize; - GLuint GreenSize; - GLuint BlueSize; - GLuint AlphaSize; - GLuint LuminanceSize; - GLuint Count[HISTOGRAM_TABLE_SIZE][4]; + GLuint Width; /* number of table entries */ + GLint Format; /* GL_ALPHA, GL_RGB, etc */ + GLuint Count[HISTOGRAM_TABLE_SIZE][4]; /* the histogram */ + GLboolean Sink; /* terminate image transfer? */ + GLubyte RedSize; /* Bits per counter */ + GLubyte GreenSize; + GLubyte BlueSize; + GLubyte AlphaSize; + GLubyte LuminanceSize; }; @@ -766,11 +766,14 @@ struct gl_stencil_attrib { #define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i)) -typedef void (*FetchTexelFunc)( GLcontext *ctx, - const struct gl_texture_object *texObject, - const struct gl_texture_image *texImage, +/* + * If teximage is color-index, texelOut returns GLchan[1]. + * If teximage is depth, texelOut returns GLfloat[1]. + * Otherwise, texelOut returns GLchan[4]. + */ +typedef void (*FetchTexelFunc)( const struct gl_texture_image *texImage, GLint col, GLint row, GLint img, - GLchan texel[] ); + GLvoid *texelOut ); /* Texture image record */ @@ -817,18 +820,20 @@ struct gl_texture_object { _glthread_Mutex Mutex; /* for thread safety */ GLint RefCount; /* reference count */ GLuint Name; /* an unsigned integer */ - GLuint Dimensions; /* 1 or 2 or 3 */ + GLuint Dimensions; /* 1 or 2 or 3 or 6 (cube map) */ GLfloat Priority; /* in [0,1] */ - GLchan BorderColor[4]; /* as integers */ + GLchan BorderColor[4]; GLenum WrapS; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */ GLenum WrapT; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */ GLenum WrapR; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */ GLenum MinFilter; /* minification filter */ GLenum MagFilter; /* magnification filter */ - GLfloat MinLod; /* OpenGL 1.2 */ - GLfloat MaxLod; /* OpenGL 1.2 */ - GLint BaseLevel; /* user-specified, OpenGL 1.2 */ - GLint MaxLevel; /* user-specified, OpenGL 1.2 */ + GLfloat MinLod; /* min lambda, OpenGL 1.2 */ + GLfloat MaxLod; /* max lambda, OpenGL 1.2 */ + GLint BaseLevel; /* min mipmap level, OpenGL 1.2 */ + GLint MaxLevel; /* max mipmap level, OpenGL 1.2 */ + GLboolean CompareFlag; /* GL_SGIX_shadow */ + GLenum CompareOperator; /* GL_SGIX_shadow */ 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]; @@ -1224,6 +1229,7 @@ struct gl_extensions { GLboolean SGIS_texture_edge_clamp; GLboolean SGIX_depth_texture; GLboolean SGIX_pixel_texture; + GLboolean SGIX_shadow; GLboolean _3DFX_texture_compression_FXT1; }; diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index fe5fb449810..e534924e80c 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1,4 +1,4 @@ -/* $Id: teximage.c,v 1.76 2001/02/17 00:15:39 brianp Exp $ */ +/* $Id: teximage.c,v 1.77 2001/02/17 18:41:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1180,7 +1180,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, GLint col; GLfloat *dst = tmpImage + row * width * 4; for (col = 0; col < width; col++) { - (*texImage->FetchTexel)(ctx, texObj, texImage, col, row, img, + (*texImage->FetchTexel)(texImage, col, row, img, texels[col]); } _mesa_unpack_float_color_span(ctx, width, GL_RGBA, dst, @@ -1244,28 +1244,19 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, GLuint indexRow[MAX_WIDTH]; GLint col; for (col = 0; col < width; col++) { - GLchan rgba[1]; - /* XXX this won't really work yet */ - /*need (*texImage->FetchRawTexel)() */ - (*texImage->FetchTexel)(ctx, texObj, texImage, - col, row, img, rgba); - indexRow[col] = rgba[0]; + (*texImage->FetchTexel)(texImage, col, row, img, + (GLvoid *) &indexRow[col]); } _mesa_pack_index_span(ctx, width, type, dest, indexRow, &ctx->Pack, ctx->_ImageTransferState); } else if (format == GL_DEPTH_COMPONENT) { - /* XXX finish this */ GLfloat depthRow[MAX_WIDTH]; GLint col; for (col = 0; col < width; col++) { - GLchan rgba[1]; - /* XXX this won't really work yet */ - /*need (*texImage->FetchRawTexel)() */ - (*texImage->FetchTexel)(ctx, texObj, texImage, - col, row, img, rgba); - depthRow[col] = (GLfloat) rgba[0]; + (*texImage->FetchTexel)(texImage, col, row, img, + (GLvoid *) &depthRow[col]); } _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack); @@ -1275,12 +1266,12 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, GLchan rgba[MAX_WIDTH][4]; GLint col; for (col = 0; col < width; col++) { - (*texImage->FetchTexel)(ctx, texObj, texImage, - col, row, img, rgba[col]); + (*texImage->FetchTexel)(texImage, col, row, img, + (GLvoid *) rgba[col]); } - _mesa_pack_rgba_span( ctx, width, (const GLchan (*)[4])rgba, - format, type, dest, &ctx->Pack, - ctx->_ImageTransferState ); + _mesa_pack_rgba_span(ctx, width, (const GLchan (*)[4])rgba, + format, type, dest, &ctx->Pack, + ctx->_ImageTransferState); } /* format */ } /* row */ } /* img */ diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 0ce694ae1d7..95427855fba 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -1,4 +1,4 @@ -/* $Id: texobj.c,v 1.38 2001/01/29 20:47:39 keithw Exp $ */ +/* $Id: texobj.c,v 1.39 2001/02/17 18:41:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -79,6 +79,8 @@ _mesa_alloc_texture_object( struct gl_shared_state *shared, obj->MaxLod = 1000.0; obj->BaseLevel = 0; obj->MaxLevel = 1000; + obj->CompareFlag = GL_FALSE; + obj->CompareOperator = GL_TEXTURE_LEQUAL_R_SGIX; _mesa_init_colortable(&obj->Palette); /* insert into linked list */ diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index ecfd5c59b31..f55cb5452a0 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -1,4 +1,4 @@ -/* $Id: texstate.c,v 1.31 2001/02/17 00:15:39 brianp Exp $ */ +/* $Id: texstate.c,v 1.32 2001/02/17 18:41:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -770,6 +770,31 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) /* ([email protected]) */ texObj->Priority = CLAMP( params[0], 0.0F, 1.0F ); break; + case GL_TEXTURE_COMPARE_SGIX: + if (ctx->Extensions.SGIX_shadow) { + texObj->CompareFlag = params[0] ? GL_TRUE : GL_FALSE; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname)"); + return; + } + break; + case GL_TEXTURE_COMPARE_OPERATOR_SGIX: + if (ctx->Extensions.SGIX_shadow) { + GLenum op = (GLenum) params[0]; + if (op == GL_TEXTURE_LEQUAL_R_SGIX || + op == GL_TEXTURE_GEQUAL_R_SGIX) { + texObj->CompareFlag = (GLenum) op; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glTexParameter(param)"); + } + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname)"); + return; + } + break; default: gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(pname)" ); return; @@ -1021,6 +1046,24 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) case GL_TEXTURE_MAX_LEVEL: *params = (GLfloat) obj->MaxLevel; break; + case GL_TEXTURE_COMPARE_SGIX: + if (ctx->Extensions.SGIX_shadow) { + *params = (GLfloat) obj->CompareFlag; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" ); + return; + } + break; + case GL_TEXTURE_COMPARE_OPERATOR_SGIX: + if (ctx->Extensions.SGIX_shadow) { + *params = (GLfloat) obj->CompareOperator; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" ); + return; + } + break; default: gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" ); } @@ -1095,6 +1138,24 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) case GL_TEXTURE_MAX_LEVEL: *params = obj->MaxLevel; break; + case GL_TEXTURE_COMPARE_SGIX: + if (ctx->Extensions.SGIX_shadow) { + *params = (GLint) obj->CompareFlag; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)" ); + return; + } + break; + case GL_TEXTURE_COMPARE_OPERATOR_SGIX: + if (ctx->Extensions.SGIX_shadow) { + *params = (GLint) obj->CompareOperator; + } + 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/main/texstore.c b/src/mesa/main/texstore.c index 224f79dd783..8f0f4fc64cb 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1,4 +1,4 @@ -/* $Id: texstore.c,v 1.5 2001/02/17 00:15:39 brianp Exp $ */ +/* $Id: texstore.c,v 1.6 2001/02/17 18:41:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -38,6 +38,7 @@ +#include "colormac.h" #include "context.h" #include "convolve.h" #include "image.h" @@ -47,57 +48,6 @@ #include "texstore.h" -/* - * Get texture palette entry. - */ -static void -palette_sample(GLcontext *ctx, - const struct gl_texture_object *tObj, - GLint index, GLchan rgba[4] ) -{ - const GLchan *palette; - GLenum format; - - if (ctx->Texture.SharedPalette) { - ASSERT(!ctx->Texture.Palette.FloatTable); - palette = (const GLchan *) ctx->Texture.Palette.Table; - format = ctx->Texture.Palette.Format; - } - else { - ASSERT(!tObj->Palette.FloatTable); - palette = (const GLchan *) tObj->Palette.Table; - format = tObj->Palette.Format; - } - - switch (format) { - case GL_ALPHA: - rgba[ACOMP] = palette[index]; - return; - case GL_LUMINANCE: - case GL_INTENSITY: - rgba[RCOMP] = palette[index]; - return; - case GL_LUMINANCE_ALPHA: - rgba[RCOMP] = palette[(index << 1) + 0]; - rgba[ACOMP] = palette[(index << 1) + 1]; - return; - case GL_RGB: - rgba[RCOMP] = palette[index * 3 + 0]; - rgba[GCOMP] = palette[index * 3 + 1]; - rgba[BCOMP] = palette[index * 3 + 2]; - return; - case GL_RGBA: - rgba[RCOMP] = palette[(index << 2) + 0]; - rgba[GCOMP] = palette[(index << 2) + 1]; - rgba[BCOMP] = palette[(index << 2) + 2]; - rgba[ACOMP] = palette[(index << 2) + 3]; - return; - default: - gl_problem(NULL, "Bad palette format in palette_sample"); - } -} - - /* * Default 1-D texture texel fetch function. This will typically be @@ -105,61 +55,65 @@ palette_sample(GLcontext *ctx, * special ways. */ static void -fetch_1d_texel(GLcontext *ctx, - const struct gl_texture_object *tObj, - const struct gl_texture_image *img, - GLint i, GLint j, GLint k, GLchan rgba[4]) +fetch_1d_texel(const struct gl_texture_image *img, + GLint i, GLint j, GLint k, GLvoid *texel) { - const GLchan *data = (GLchan *) img->Data; - const GLchan *texel; -#ifdef DEBUG - GLint width = img->Width; - assert(i >= 0); - assert(i < width); -#endif - switch (img->Format) { - case GL_COLOR_INDEX: - { - GLint index = data[i]; - palette_sample(ctx, tObj, index, rgba); - return; - } - case GL_ALPHA: - rgba[ACOMP] = data[i]; + case GL_RGBA: + { + const GLchan *src = (GLchan *) img->Data + i * 4; + GLchan *rgba = (GLchan *) texel; + COPY_CHAN4(rgba, src); return; - case GL_LUMINANCE: - case GL_INTENSITY: - rgba[RCOMP] = data[i]; + } + case GL_RGB: + { + const GLchan *src = (GLchan *) img->Data + i * 3; + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = src[0]; + rgba[GCOMP] = src[1]; + rgba[BCOMP] = src[2]; return; - case GL_LUMINANCE_ALPHA: - texel = data + i * 2; - rgba[RCOMP] = texel[0]; - rgba[ACOMP] = texel[1]; + } + case GL_ALPHA: + { + const GLchan *src = (GLchan *) img->Data + i; + GLchan *rgba = (GLchan *) texel; + rgba[ACOMP] = src[0]; return; - case GL_RGB: - texel = data + i * 3; - rgba[RCOMP] = texel[0]; - rgba[GCOMP] = texel[1]; - rgba[BCOMP] = texel[2]; + } + case GL_LUMINANCE: + case GL_INTENSITY: + { + const GLchan *src = (GLchan *) img->Data + i; + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = src[0]; return; - case GL_RGBA: - texel = data + i * 4; - rgba[RCOMP] = texel[0]; - rgba[GCOMP] = texel[1]; - rgba[BCOMP] = texel[2]; - rgba[ACOMP] = texel[3]; + } + case GL_LUMINANCE_ALPHA: + { + const GLchan *src = (GLchan *) img->Data + i * 2; + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = src[0]; + rgba[ACOMP] = src[1]; return; - case GL_DEPTH_COMPONENT: - { - const GLfloat *data = (const GLfloat *) img->Data; - GLfloat *texel = (GLfloat *) rgba; - *texel = data[i]; - return; - } - default: - gl_problem(NULL, "Bad format in fetch_1d_texel"); + } + case GL_COLOR_INDEX: + { + const GLchan *src = (GLchan *) img->Data + i; + GLchan *index = (GLchan *) texel; + *index = *src; return; + } + case GL_DEPTH_COMPONENT: + { + const GLfloat *src = (GLfloat *) img->Data + i; + GLfloat *depth = (GLfloat *) texel; + *depth = *src; + return; + } + default: + gl_problem(NULL, "Bad format in fetch_1d_texel"); } } @@ -168,64 +122,65 @@ fetch_1d_texel(GLcontext *ctx, * Default 2-D texture texel fetch function. */ static void -fetch_2d_texel(GLcontext *ctx, - const struct gl_texture_object *tObj, - const struct gl_texture_image *img, - GLint i, GLint j, GLint k, GLchan rgba[4]) +fetch_2d_texel(const struct gl_texture_image *img, + GLint i, GLint j, GLint k, GLvoid *texel) { - const GLint width = img->Width; /* includes border */ - const GLchan *data = (GLchan *) img->Data; - const GLchan *texel; - -#ifdef DEBUG - const GLint height = img->Height; /* includes border */ - assert(i >= 0); - assert(i < width); - assert(j >= 0); - assert(j < height); -#endif - switch (img->Format) { - case GL_COLOR_INDEX: - { - GLint index = data[width *j + i]; - palette_sample(ctx, tObj, index, rgba ); - return; - } - case GL_ALPHA: - rgba[ACOMP] = data[width * j + i]; + case GL_RGBA: + { + const GLchan *src = (GLchan *) img->Data + (img->Width * j + i) * 4; + GLchan *rgba = (GLchan *) texel; + COPY_CHAN4(rgba, src); return; - case GL_LUMINANCE: - case GL_INTENSITY: - rgba[RCOMP] = data[ width * j + i]; + } + case GL_RGB: + { + const GLchan *src = (GLchan *) img->Data + (img->Width * j + i) * 3; + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = src[0]; + rgba[GCOMP] = src[1]; + rgba[BCOMP] = src[2]; return; - case GL_LUMINANCE_ALPHA: - texel = data + (width * j + i) * 2; - rgba[RCOMP] = texel[0]; - rgba[ACOMP] = texel[1]; + } + case GL_ALPHA: + { + const GLchan *src = (GLchan *) img->Data + (img->Width * j + i); + GLchan *rgba = (GLchan *) texel; + rgba[ACOMP] = src[0]; return; - case GL_RGB: - texel = data + (width * j + i) * 3; - rgba[RCOMP] = texel[0]; - rgba[GCOMP] = texel[1]; - rgba[BCOMP] = texel[2]; + } + case GL_LUMINANCE: + case GL_INTENSITY: + { + const GLchan *src = (GLchan *) img->Data + (img->Width * j + i); + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = src[0]; return; - case GL_RGBA: - texel = data + (width * j + i) * 4; - rgba[RCOMP] = texel[0]; - rgba[GCOMP] = texel[1]; - rgba[BCOMP] = texel[2]; - rgba[ACOMP] = texel[3]; + } + case GL_LUMINANCE_ALPHA: + { + const GLchan *src = (GLchan *) img->Data + (img->Width * j + i) * 2; + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = src[0]; + rgba[ACOMP] = src[1]; return; - case GL_DEPTH_COMPONENT: - { - const GLfloat *data = (const GLfloat *) img->Data; - GLfloat *texel = (GLfloat *) rgba; - *texel = data[width * j + i]; - return; - } - default: - gl_problem(NULL, "Bad format in fetch_2d_texel"); + } + case GL_COLOR_INDEX: + { + const GLchan *src = (GLchan *) img->Data + (img->Width * j + i); + GLchan *index = (GLchan *) texel; + *index = *src; + return; + } + case GL_DEPTH_COMPONENT: + { + const GLfloat *src = (GLfloat *) img->Data + (img->Width * j + i); + GLfloat *depth = (GLfloat *) texel; + *depth = *src; + return; + } + default: + gl_problem(NULL, "Bad format in fetch_2d_texel"); } } @@ -234,68 +189,75 @@ fetch_2d_texel(GLcontext *ctx, * Default 2-D texture texel fetch function. */ static void -fetch_3d_texel(GLcontext *ctx, - const struct gl_texture_object *tObj, - const struct gl_texture_image *img, - GLint i, GLint j, GLint k, GLchan rgba[4]) +fetch_3d_texel(const struct gl_texture_image *img, + GLint i, GLint j, GLint k, GLvoid *texel) { - const GLint width = img->Width; /* includes border */ - const GLint height = img->Height; /* includes border */ - const GLint rectarea = width * height; - const GLchan *data = (GLchan *) img->Data; - const GLchan *texel; - -#ifdef DEBUG - const GLint depth = img->Depth; /* includes border */ - assert(i >= 0); - assert(i < width); - assert(j >= 0); - assert(j < height); - assert(k >= 0); - assert(k < depth); -#endif + const GLint width = img->Width; + const GLint rectArea = width * img->Height; switch (img->Format) { - case GL_COLOR_INDEX: - { - GLint index = data[ rectarea * k + width * j + i ]; - palette_sample(ctx, tObj, index, rgba ); - return; - } - case GL_ALPHA: - rgba[ACOMP] = data[ rectarea * k + width * j + i ]; + case GL_RGBA: + { + const GLchan *src = (GLchan *) img->Data + + (rectArea * k + width * j + i) * 4; + GLchan *rgba = (GLchan *) texel; + COPY_CHAN4(rgba, src); return; - case GL_LUMINANCE: - case GL_INTENSITY: - rgba[RCOMP] = data[ rectarea * k + width * j + i ]; + } + case GL_RGB: + { + const GLchan *src = (GLchan *) img->Data + + (rectArea * k + width * j + i) * 3; + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = src[0]; + rgba[GCOMP] = src[1]; + rgba[BCOMP] = src[2]; return; - case GL_LUMINANCE_ALPHA: - texel = data + ( rectarea * k + width * j + i) * 2; - rgba[RCOMP] = texel[0]; - rgba[ACOMP] = texel[1]; + } + case GL_ALPHA: + { + const GLchan *src = (GLchan *) img->Data + + (rectArea * k + width * j + i); + GLchan *rgba = (GLchan *) texel; + rgba[ACOMP] = src[0]; return; - case GL_RGB: - texel = data + (rectarea * k + width * j + i) * 3; - rgba[RCOMP] = texel[0]; - rgba[GCOMP] = texel[1]; - rgba[BCOMP] = texel[2]; + } + case GL_LUMINANCE: + case GL_INTENSITY: + { + const GLchan *src = (GLchan *) img->Data + + (rectArea * k + width * j + i); + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = src[0]; return; - case GL_RGBA: - texel = data + (rectarea * k + width * j + i) * 4; - rgba[RCOMP] = texel[0]; - rgba[GCOMP] = texel[1]; - rgba[BCOMP] = texel[2]; - rgba[ACOMP] = texel[3]; + } + case GL_LUMINANCE_ALPHA: + { + const GLchan *src = (GLchan *) img->Data + + (rectArea * k + width * j + i) * 2; + GLchan *rgba = (GLchan *) texel; + rgba[RCOMP] = src[0]; + rgba[ACOMP] = src[1]; return; - case GL_DEPTH_COMPONENT: - { - const GLfloat *data = (const GLfloat *) img->Data; - GLfloat *texel = (GLfloat *) rgba; - *texel = data[rectarea * k + width * j + i]; - return; - } - default: - gl_problem(NULL, "Bad format in fetch_3d_texel"); + } + case GL_COLOR_INDEX: + { + const GLchan *src = (GLchan *) img->Data + + (rectArea * k + width * j + i); + GLchan *index = (GLchan *) texel; + *index = *src; + return; + } + case GL_DEPTH_COMPONENT: + { + const GLfloat *src = (GLfloat *) img->Data + + (rectArea * k + width * j + i); + GLfloat *depth = (GLfloat *) texel; + *depth = *src; + return; + } + default: + gl_problem(NULL, "Bad format in fetch_3d_texel"); } } @@ -640,7 +602,6 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions, } else if (texFormat == GL_DEPTH_COMPONENT) { /* Depth texture (shadow maps) */ - const GLenum texType = GL_FLOAT; GLint img, row; GLfloat *dest = (GLfloat *) texAddr + dstZoffset * dstImageStride + dstYoffset * dstRowStride @@ -650,14 +611,8 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions, for (row = 0; row < srcHeight; row++) { const GLvoid *src = _mesa_image_address(srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - (void) src; - (void) texType; - /* XXX destRow: GLfloat vs. GLdepth? */ - /* - _mesa_unpack_depth_span(ctx, srcWidth, texType, destRow, - srcType, src, srcPacking, - ctx->_ImageTransferState); - */ + _mesa_unpack_depth_span(ctx, srcWidth, destRow, + srcType, src, srcPacking); destRow += dstRowStride; } dest += dstImageStride; diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 757f1ab0717..24339f61bbc 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.8 2001/01/23 23:39:37 brianp Exp $ */ +/* $Id: s_drawpix.c,v 1.9 2001/02/17 18:41:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -653,11 +653,21 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, /* General case */ GLint row; for (row = 0; row < height; row++, y++) { + GLfloat fspan[MAX_WIDTH]; GLdepth zspan[MAX_WIDTH]; const GLvoid *src = _mesa_image_address(&ctx->Unpack, pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0); - _mesa_unpack_depth_span( ctx, drawWidth, zspan, type, src, - &ctx->Unpack, ctx->_ImageTransferState ); + _mesa_unpack_depth_span( ctx, drawWidth, fspan, type, src, + &ctx->Unpack ); + /* clamp depth values to [0,1] and convert from floats to integers */ + { + const GLfloat zs = ctx->DepthMaxF; + GLuint i; + for (i = 0; i < drawWidth; i++) { + zspan[i] = (GLdepth) (fspan[i] * zs); + } + } + if (ctx->Visual.rgbMode) { if (zoom) { gl_write_zoomed_rgba_span(ctx, width, x, y, zspan, 0, diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index b562a0037e9..2a7d3db460e 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.10 2001/02/07 03:55:31 brianp Exp $ */ +/* $Id: s_texture.c,v 1.11 2001/02/17 18:41:01 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -155,6 +155,58 @@ +/* + * Get texture palette entry. + */ +static void +palette_sample(const GLcontext *ctx, + const struct gl_texture_object *tObj, + GLint index, GLchan rgba[4] ) +{ + const GLchan *palette; + GLenum format; + + if (ctx->Texture.SharedPalette) { + ASSERT(!ctx->Texture.Palette.FloatTable); + palette = (const GLchan *) ctx->Texture.Palette.Table; + format = ctx->Texture.Palette.Format; + } + else { + ASSERT(!tObj->Palette.FloatTable); + palette = (const GLchan *) tObj->Palette.Table; + format = tObj->Palette.Format; + } + + switch (format) { + case GL_ALPHA: + rgba[ACOMP] = palette[index]; + return; + case GL_LUMINANCE: + case GL_INTENSITY: + rgba[RCOMP] = palette[index]; + return; + case GL_LUMINANCE_ALPHA: + rgba[RCOMP] = palette[(index << 1) + 0]; + rgba[ACOMP] = palette[(index << 1) + 1]; + return; + case GL_RGB: + rgba[RCOMP] = palette[index * 3 + 0]; + rgba[GCOMP] = palette[index * 3 + 1]; + rgba[BCOMP] = palette[index * 3 + 2]; + return; + case GL_RGBA: + rgba[RCOMP] = palette[(index << 2) + 0]; + rgba[GCOMP] = palette[(index << 2) + 1]; + rgba[BCOMP] = palette[(index << 2) + 2]; + rgba[ACOMP] = palette[(index << 2) + 3]; + return; + default: + gl_problem(ctx, "Bad palette format in palette_sample"); + } +} + + + /**********************************************************************/ /* 1-D Texture Sampling Functions */ /**********************************************************************/ @@ -176,7 +228,10 @@ sample_1d_nearest(GLcontext *ctx, /* skip over the border, if any */ i += img->Border; - (*img->FetchTexel)(ctx, tObj, img, i, 0, 0, rgba); + (*img->FetchTexel)(img, i, 0, 0, (GLvoid *) rgba); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, rgba[0], rgba); + } } @@ -219,13 +274,19 @@ sample_1d_linear(GLcontext *ctx, COPY_CHAN4(t0, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i0, 0, 0, t0); + (*img->FetchTexel)(img, i0, 0, 0, (GLvoid *) t0); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t0[0], t0); + } } if (useBorderColor & I1BIT) { COPY_CHAN4(t1, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i1, 0, 0, t1); + (*img->FetchTexel)(img, i1, 0, 0, (GLvoid *) t1); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t1[0], t1); + } } rgba[0] = (GLchan) ((w0 * t0[0] + w1 * t1[0]) >> WEIGHT_SHIFT); @@ -451,7 +512,10 @@ sample_2d_nearest(GLcontext *ctx, i += img->Border; j += img->Border; - (*img->FetchTexel)(ctx, tObj, img, i, j, 0, rgba); + (*img->FetchTexel)(img, i, j, 0, (GLvoid *) rgba); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, rgba[0], rgba); + } } @@ -507,25 +571,37 @@ sample_2d_linear(GLcontext *ctx, COPY_CHAN4(t00, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i0, j0, 0, t00); + (*img->FetchTexel)(img, i0, j0, 0, (GLvoid *) t00); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t00[0], t00); + } } if (useBorderColor & (I1BIT | J0BIT)) { COPY_CHAN4(t10, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i1, j0, 0, t10); + (*img->FetchTexel)(img, i1, j0, 0, (GLvoid *) t10); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t10[0], t10); + } } if (useBorderColor & (I0BIT | J1BIT)) { COPY_CHAN4(t01, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i0, j1, 0, t01); + (*img->FetchTexel)(img, i0, j1, 0, (GLvoid *) t01); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t01[0], t01); + } } if (useBorderColor & (I1BIT | J1BIT)) { COPY_CHAN4(t11, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i1, j1, 0, t11); + (*img->FetchTexel)(img, i1, j1, 0, (GLvoid *) t11); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t11[0], t11); + } } rgba[0] = (GLchan) ((w00 * t00[0] + w10 * t10[0] + w01 * t01[0] + w11 * t11[0]) >> WEIGHT_SHIFT); @@ -852,7 +928,10 @@ sample_3d_nearest(GLcontext *ctx, COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapT, t, height, j); COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapR, r, depth, k); - (*img->FetchTexel)(ctx, tObj, img, i, j, k, rgba); + (*img->FetchTexel)(img, i, j, k, (GLvoid *) rgba); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, rgba[0], rgba); + } } @@ -918,50 +997,74 @@ sample_3d_linear(GLcontext *ctx, COPY_CHAN4(t000, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i0, j0, k0, t000); + (*img->FetchTexel)(img, i0, j0, k0, (GLvoid *) t000); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t000[0], t000); + } } if (useBorderColor & (I1BIT | J0BIT | K0BIT)) { COPY_CHAN4(t100, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i1, j0, k0, t100); + (*img->FetchTexel)(img, i1, j0, k0, (GLvoid *) t100); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t100[0], t100); + } } if (useBorderColor & (I0BIT | J1BIT | K0BIT)) { COPY_CHAN4(t010, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i0, j1, k0, t010); + (*img->FetchTexel)(img, i0, j1, k0, (GLvoid *) t010); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t010[0], t010); + } } if (useBorderColor & (I1BIT | J1BIT | K0BIT)) { COPY_CHAN4(t110, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i1, j1, k0, t110); + (*img->FetchTexel)(img, i1, j1, k0, (GLvoid *) t110); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t110[0], t110); + } } if (useBorderColor & (I0BIT | J0BIT | K1BIT)) { COPY_CHAN4(t001, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i0, j0, k1, t001); + (*img->FetchTexel)(img, i0, j0, k1, (GLvoid *) t001); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t001[0], t001); + } } if (useBorderColor & (I1BIT | J0BIT | K1BIT)) { COPY_CHAN4(t101, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i1, j0, k1, t101); + (*img->FetchTexel)(img, i1, j0, k1, (GLvoid *) t101); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t101[0], t101); + } } if (useBorderColor & (I0BIT | J1BIT | K1BIT)) { COPY_CHAN4(t011, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i0, j1, k1, t011); + (*img->FetchTexel)(img, i0, j1, k1, (GLvoid *) t011); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t011[0], t011); + } } if (useBorderColor & (I1BIT | J1BIT | K1BIT)) { COPY_CHAN4(t111, tObj->BorderColor); } else { - (*img->FetchTexel)(ctx, tObj, img, i1, j1, k1, t111); + (*img->FetchTexel)(img, i1, j1, k1, (GLvoid *) t111); + if (img->Format == GL_COLOR_INDEX) { + palette_sample(ctx, tObj, t111[0], t111); + } } rgba[0] = (GLchan) ( |