Implemented glGetTexImage(format=GL_COLOR_INDEX).
Changed _mesa_unpack_depth_span() args.
Minor changes/clean-ups in mtypes.h.
Histogram counter component sizes were wrong.
*/
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;
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;
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;
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;
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;
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;
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;
-/* $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
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;
-/* $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
{ 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) }
};
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 */
}
-/* $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
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;
-/* $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
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;
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;
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;
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;
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;
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);
}
-/* $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
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,
-/* $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
/* 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;
};
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 */
};
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;
};
#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 */
_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];
GLboolean SGIS_texture_edge_clamp;
GLboolean SGIX_depth_texture;
GLboolean SGIX_pixel_texture;
+ GLboolean SGIX_shadow;
GLboolean _3DFX_texture_compression_FXT1;
};
-/* $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
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,
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);
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 */
-/* $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
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 */
-/* $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
/* (keithh@netcomuk.co.uk) */
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;
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)" );
}
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)" );
}
-/* $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
+#include "colormac.h"
#include "context.h"
#include "convolve.h"
#include "image.h"
#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
* 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");
}
}
* 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");
}
}
* 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");
}
}
}
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
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;
-/* $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
/* 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,
-/* $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
+/*
+ * 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 */
/**********************************************************************/
/* 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);
+ }
}
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);
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);
+ }
}
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);
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);
+ }
}
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) (