summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-02-17 18:41:01 +0000
committerBrian Paul <[email protected]>2001-02-17 18:41:01 +0000
commite75d2424e53d6023f4414e40694cd467e5392b96 (patch)
treead354e0042460ae53e689229498872625e07d412 /src/mesa/main
parent8f9a594ac8116ed5cab7f8eca14c17ec3e250dad (diff)
Changed FetchTexel() function pointer arguments.
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.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/context.c12
-rw-r--r--src/mesa/main/extensions.c4
-rw-r--r--src/mesa/main/histogram.c12
-rw-r--r--src/mesa/main/image.c42
-rw-r--r--src/mesa/main/image.h7
-rw-r--r--src/mesa/main/mtypes.h70
-rw-r--r--src/mesa/main/teximage.c31
-rw-r--r--src/mesa/main/texobj.c4
-rw-r--r--src/mesa/main/texstate.c63
-rw-r--r--src/mesa/main/texstore.c381
10 files changed, 313 insertions, 313 deletions
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 )
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;