-/* $Id: extensions.c,v 1.66 2001/11/19 00:41:32 brianp Exp $ */
+/* $Id: extensions.c,v 1.67 2001/12/04 23:44:55 brianp Exp $ */
/*
* Mesa 3-D graphics library
const char *name;
int flag_offset;
} default_extensions[] = {
+ { OFF, "GL_ARB_depth_texture", F(SGIX_depth_texture) },
{ OFF, "GL_ARB_imaging", F(ARB_imaging) },
{ OFF, "GL_ARB_multisample", F(ARB_multisample) },
{ OFF, "GL_ARB_multitexture", F(ARB_multitexture) },
+ { OFF, "GL_ARB_shadow", F(ARB_shadow) },
+ { OFF, "GL_ARB_shadow_ambient", F(SGIX_shadow_ambient) },
{ OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) },
{ OFF, "GL_ARB_texture_compression", F(ARB_texture_compression) },
{ OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) },
_mesa_enable_sw_extensions(GLcontext *ctx)
{
const char *extensions[] = {
+ "GL_ARB_depth_texture",
"GL_ARB_imaging",
"GL_ARB_multitexture",
+ "GL_ARB_shadow",
+ "GL_ARB_shadow_ambient",
"GL_ARB_texture_border_clamp",
"GL_ARB_texture_cube_map",
"GL_ARB_texture_env_add",
-/* $Id: get.c,v 1.72 2001/11/06 15:53:00 brianp Exp $ */
+/* $Id: get.c,v 1.73 2001/12/04 23:44:56 brianp Exp $ */
/*
* Mesa 3-D graphics library
GET_CURRENT_CONTEXT(ctx);
static const char *vendor = "Brian Paul";
static const char *renderer = "Mesa";
- static const char *version_1_2 = "1.2 Mesa 4.1";
- static const char *version_1_3 = "1.3 Mesa 4.1";
+ static const char *version_1_2 = "1.2 Mesa 4.1 beta";
+ static const char *version_1_3 = "1.3 Mesa 4.1 beta";
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
-/* $Id: mtypes.h,v 1.53 2001/11/18 23:52:37 brianp Exp $ */
+/* $Id: mtypes.h,v 1.54 2001/12/04 23:44:56 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLenum DrawBuffer; /* Which buffer to draw into */
GLenum DriverDrawBuffer; /* Current device driver dest buffer */
- GLboolean MultiDrawBuffer; /* Drawing to mutliple buffers? */
+ GLboolean MultiDrawBuffer; /* Drawing to multiple buffers? */
GLubyte DrawDestMask; /* bitwise-OR of bitflags above */
/* alpha testing */
GLboolean MapColorFlag;
GLboolean MapStencilFlag;
GLfloat ZoomX, ZoomY;
+ /* XXX move these out of gl_pixel_attrib */
GLint MapStoSsize; /* Size of each pixel map */
GLint MapItoIsize;
GLint MapItoRsize;
GLuint Name; /* an unsigned integer */
GLuint Dimensions; /* 1 or 2 or 3 or 6 (cube map) */
GLfloat Priority; /* in [0,1] */
- GLchan BorderColor[4];
+ GLfloat BorderValues[4]; /* unclamped */
+ GLchan BorderColor[4]; /* clamped, as GLchan */
GLenum WrapS; /* Wrap modes are: GL_CLAMP, REPEAT */
GLenum WrapT; /* GL_CLAMP_TO_EDGE, and */
GLenum WrapR; /* GL_CLAMP_TO_BORDER_ARB */
GLfloat MaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
GLboolean CompareFlag; /* GL_SGIX_shadow */
GLenum CompareOperator; /* GL_SGIX_shadow */
- GLchan ShadowAmbient; /* GL_SGIX_shadow_ambient */
+ GLchan ShadowAmbient; /* GL_SGIX/ARB_shadow_ambient */
+ GLenum CompareMode; /* GL_ARB_shadow */
+ GLenum CompareFunc; /* GL_ARB_shadow */
+ GLenum CompareResult; /* GL_ARB_shadow */
GLint _MaxLevel; /* actual max mipmap level (q in the spec) */
GLfloat _MaxLambda; /* = _MaxLevel - BaseLevel (q - b in spec) */
GLboolean GenerateMipmap; /* GL_SGIS_generate_mipmap */
GLboolean ARB_imaging;
GLboolean ARB_multisample;
GLboolean ARB_multitexture;
+ GLboolean ARB_shadow;
GLboolean ARB_texture_border_clamp;
GLboolean ARB_texture_compression;
GLboolean ARB_texture_cube_map;
GLboolean SGIS_generate_mipmap;
GLboolean SGIS_pixel_texture;
GLboolean SGIS_texture_edge_clamp;
- GLboolean SGIX_depth_texture;
+ GLboolean SGIX_depth_texture; /* or GL_ARB_depth_texture */
GLboolean SGIX_pixel_texture;
GLboolean SGIX_shadow;
- GLboolean SGIX_shadow_ambient;
+ GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
GLboolean _3DFX_texture_compression_FXT1;
};
-/* $Id: texobj.c,v 1.50 2001/07/27 14:30:50 brianp Exp $ */
+/* $Id: texobj.c,v 1.51 2001/12/04 23:44:56 brianp Exp $ */
/*
* Mesa 3-D graphics library
obj->BaseLevel = 0;
obj->MaxLevel = 1000;
obj->MaxAnisotropy = 1.0;
- obj->CompareFlag = GL_FALSE;
- obj->CompareOperator = GL_TEXTURE_LEQUAL_R_SGIX;
- obj->ShadowAmbient = 0;
+ obj->CompareFlag = GL_FALSE; /* SGIX_shadow */
+ obj->CompareOperator = GL_TEXTURE_LEQUAL_R_SGIX; /* SGIX_shadow */
+ obj->CompareMode = GL_LUMINANCE; /* ARB_shadow */
+ obj->CompareFunc = GL_LEQUAL; /* ARB_shadow */
+ obj->CompareResult = GL_LUMINANCE; /* ARB_shadow */
+ obj->ShadowAmbient = 0; /* ARB/SGIX_shadow_ambient */
_mesa_init_colortable(&obj->Palette);
/* insert into linked list */
-/* $Id: texstate.c,v 1.59 2001/11/06 15:53:00 brianp Exp $ */
+/* $Id: texstate.c,v 1.60 2001/12/04 23:44:56 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "math/m_matrix.h"
#endif
+/* TEMPORARY! */
+#ifndef GL_TEXTURE_COMPARE_MODE_ARB
+#define GL_TEXTURE_COMPARE_MODE_ARB 0x9990
+#define GL_TEXTURE_COMPARE_FUNC_ARB 0x9991
+#define GL_TEXTURE_COMPARE_RESULT_ARB 0x9992
+#define GL_COMPARE_R_TO_TEXTURE_ARB 0x9993
+#endif
#ifdef SPECIALCAST
_mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
}
break;
- case GL_TEXTURE_BORDER_COLOR:
+#if 0 /* someday */
+ case GL_TEXTUER_BORDER_VALUES_NV:
+ /* don't clamp */
+ COPY_4V(texObj->BorderValues, params);
UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[0], params[0]);
UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[1], params[1]);
UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[2], params[2]);
UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[3], params[3]);
break;
+#endif
+ case GL_TEXTURE_BORDER_COLOR:
+ /* clamp */
+ texObj->BorderValues[0] = CLAMP(params[0], 0.0F, 1.0F);
+ texObj->BorderValues[1] = CLAMP(params[1], 0.0F, 1.0F);
+ texObj->BorderValues[2] = CLAMP(params[2], 0.0F, 1.0F);
+ texObj->BorderValues[3] = CLAMP(params[3], 0.0F, 1.0F);
+ UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[0], texObj->BorderValues[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[1], texObj->BorderValues[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[2], texObj->BorderValues[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[3], texObj->BorderValues[3]);
+ break;
case GL_TEXTURE_MIN_LOD:
texObj->MinLod = params[0];
break;
return;
}
break;
- case GL_SHADOW_AMBIENT_SGIX:
+ case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
if (ctx->Extensions.SGIX_shadow_ambient) {
UNCLAMPED_FLOAT_TO_CHAN(texObj->ShadowAmbient, params[0]);
}
return;
}
break;
+ case GL_TEXTURE_COMPARE_MODE_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ const GLenum mode = (GLenum) params[0];
+ if (mode == GL_LUMINANCE || mode == GL_COMPARE_R_TO_TEXTURE_ARB) {
+ texObj->CompareMode = params[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(bad GL_TEXTURE_COMPARE_MODE_ARB)");
+ return;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=GL_TEXTURE_COMPARE_MODE_ARB)");
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_FUNC_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ const GLenum func = (GLenum) params[0];
+ if (func == GL_LEQUAL || func == GL_GEQUAL) {
+ texObj->CompareFunc = params[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(bad GL_TEXTURE_COMPARE_FUNC_ARB)");
+ return;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=GL_TEXTURE_COMPARE_FUNC_ARB)");
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_RESULT_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ const GLenum result = (GLenum) params[0];
+ if (result == GL_LUMINANCE || result == GL_INTENSITY
+ || result == GL_ALPHA) {
+ texObj->CompareResult = params[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(bad GL_TEXTURE_COMPARE_RESULT_ARB)");
+ return;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=GL_TEXTURE_COMPARE_RESULT_ARB)");
+ return;
+ }
+ break;
+
default:
{
char s[100];
case GL_TEXTURE_WRAP_R_EXT:
*params = ENUM_TO_FLOAT(obj->WrapR);
return;
+#if 0 /* someday */
+ case GL_TEXTURE_BORDER_VALUES_NV:
+ /* unclamped */
+ params[0] = obj->BorderValues[0];
+ params[1] = obj->BorderValues[1];
+ params[2] = obj->BorderValues[2];
+ params[3] = obj->BorderValues[3];
+ return;
+#endif
case GL_TEXTURE_BORDER_COLOR:
+ /* clamped */
params[0] = obj->BorderColor[0] / CHAN_MAXF;
params[1] = obj->BorderColor[1] / CHAN_MAXF;
params[2] = obj->BorderColor[2] / CHAN_MAXF;
return;
}
break;
- case GL_SHADOW_AMBIENT_SGIX:
+ case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
if (ctx->Extensions.SGIX_shadow_ambient) {
*params = CHAN_TO_FLOAT(obj->ShadowAmbient);
return;
return;
}
break;
+ case GL_TEXTURE_COMPARE_MODE_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ *params = (GLfloat) obj->CompareMode;
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_FUNC_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ *params = (GLfloat) obj->CompareFunc;
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_RESULT_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ *params = (GLfloat) obj->CompareResult;
+ return;
+ }
+ break;
default:
; /* silence warnings */
}
case GL_TEXTURE_WRAP_R_EXT:
*params = (GLint) obj->WrapR;
return;
+#if 0 /* someday */
+ case GL_TEXTURE_BORDER_VALUES_NV:
+ /* unclamped */
+ params[0] = FLOAT_TO_INT(obj->BorderValues[0]);
+ params[1] = FLOAT_TO_INT(obj->BorderValues[1]);
+ params[2] = FLOAT_TO_INT(obj->BorderValues[2]);
+ params[3] = FLOAT_TO_INT(obj->BorderValues[3]);
+ return;
+#endif
case GL_TEXTURE_BORDER_COLOR:
+ /* clamped */
{
- GLfloat color[4];
- color[0] = obj->BorderColor[0] / CHAN_MAXF;
- color[1] = obj->BorderColor[1] / CHAN_MAXF;
- color[2] = obj->BorderColor[2] / CHAN_MAXF;
- color[3] = obj->BorderColor[3] / CHAN_MAXF;
- params[0] = FLOAT_TO_INT( color[0] );
- params[1] = FLOAT_TO_INT( color[1] );
- params[2] = FLOAT_TO_INT( color[2] );
- params[3] = FLOAT_TO_INT( color[3] );
+ GLfloat b[4];
+ b[0] = CLAMP(obj->BorderValues[0], 0.0F, 1.0F);
+ b[1] = CLAMP(obj->BorderValues[1], 0.0F, 1.0F);
+ b[2] = CLAMP(obj->BorderValues[2], 0.0F, 1.0F);
+ b[3] = CLAMP(obj->BorderValues[3], 0.0F, 1.0F);
+ params[0] = FLOAT_TO_INT(b[0]);
+ params[1] = FLOAT_TO_INT(b[1]);
+ params[2] = FLOAT_TO_INT(b[2]);
+ params[3] = FLOAT_TO_INT(b[3]);
}
return;
case GL_TEXTURE_RESIDENT:
return;
}
break;
- case GL_SHADOW_AMBIENT_SGIX:
+ case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
if (ctx->Extensions.SGIX_shadow_ambient) {
- /* XXX range? */
- *params = (GLint) CHAN_TO_FLOAT(obj->ShadowAmbient);
+ GLfloat a = CHAN_TO_FLOAT(obj->ShadowAmbient);
+ *params = (GLint) FLOAT_TO_INT(a);
return;
}
break;
return;
}
break;
+ case GL_TEXTURE_COMPARE_MODE_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ *params = (GLint) obj->CompareMode;
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_FUNC_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ *params = (GLint) obj->CompareFunc;
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_RESULT_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ *params = (GLint) obj->CompareResult;
+ return;
+ }
+ break;
default:
; /* silence warnings */
}
-/* $Id: s_texture.c,v 1.42 2001/11/19 01:18:28 brianp Exp $ */
+/* $Id: s_texture.c,v 1.43 2001/12/04 23:44:56 brianp Exp $ */
/*
* Mesa 3-D graphics library
const GLuint height = texImage->Height;
const GLchan ambient = texObj->ShadowAmbient;
GLboolean lequal, gequal;
+ GLchan result;
+
+ ASSERT(texObj->Image[texObj->BaseLevel]->Format == GL_DEPTH_COMPONENT);
if (texObj->Dimensions != 2) {
_mesa_problem(ctx, "only 2-D depth textures supported at this time");
return;
}
- /* XXX the GL_SGIX_shadow extension spec doesn't say what to do if
- * GL_TEXTURE_COMPARE_SGIX == GL_TRUE but the current texture object
- * isn't a depth texture.
- */
- if (texImage->Format != GL_DEPTH_COMPONENT) {
- _mesa_problem(ctx,"GL_TEXTURE_COMPARE_SGIX enabled with non-depth texture");
- return;
+ /* XXX this could be precomputed */
+ if (texObj->CompareFlag) {
+ /* GL_SGIX_shadow */
+ if (texObj->CompareOperator == GL_TEXTURE_LEQUAL_R_SGIX) {
+ lequal = GL_TRUE;
+ gequal = GL_FALSE;
+ }
+ else {
+ ASSERT(texObj->CompareOperator == GL_TEXTURE_GEQUAL_R_SGIX);
+ lequal = GL_FALSE;
+ gequal = GL_TRUE;
+ }
}
-
- if (texObj->CompareOperator == GL_TEXTURE_LEQUAL_R_SGIX) {
- lequal = GL_TRUE;
- gequal = GL_FALSE;
+ else if (texObj->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) {
+ /* GL_ARB_shadow */
+ if (texObj->CompareFunc == GL_LEQUAL) {
+ lequal = GL_TRUE;
+ gequal = GL_FALSE;
+ }
+ else {
+ ASSERT(texObj->CompareFunc == GL_GEQUAL);
+ lequal = GL_FALSE;
+ gequal = GL_TRUE;
+ }
}
else {
- lequal = GL_FALSE;
- gequal = GL_TRUE;
+ /* Treat this depth texture as a luminance texture */
+ _mesa_warning(ctx,
+ "Treating GL_DEPTH_COMPONENT as GL_LUMINANCE not implemented yet");
+ return;
}
if (texObj->MagFilter == GL_NEAREST) {
depthSample = *((const GLfloat *) texImage->Data + row * width + col);
if ((r[i] <= depthSample && lequal) ||
(r[i] >= depthSample && gequal)) {
- texel[i][RCOMP] = CHAN_MAX;
- texel[i][GCOMP] = CHAN_MAX;
- texel[i][BCOMP] = CHAN_MAX;
- texel[i][ACOMP] = CHAN_MAX;
+ result = CHAN_MAX;
}
else {
- texel[i][RCOMP] = ambient;
- texel[i][GCOMP] = ambient;
- texel[i][BCOMP] = ambient;
+ result = ambient;
+ }
+
+ switch (texObj->CompareResult) {
+ case GL_LUMINANCE:
+ texel[i][RCOMP] = result;
+ texel[i][GCOMP] = result;
+ texel[i][BCOMP] = result;
texel[i][ACOMP] = CHAN_MAX;
+ break;
+ case GL_INTENSITY:
+ texel[i][RCOMP] = result;
+ texel[i][GCOMP] = result;
+ texel[i][BCOMP] = result;
+ texel[i][ACOMP] = result;
+ break;
+ case GL_ALPHA:
+ texel[i][RCOMP] = 0;
+ texel[i][GCOMP] = 0;
+ texel[i][BCOMP] = 0;
+ texel[i][ACOMP] = result;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad texture compare result value");
}
}
}
+ w01 * depth01 + w11 * depth11;
if ((depthSample <= r[i] && lequal) ||
(depthSample >= r[i] && gequal)) {
- texel[i][RCOMP] = ambient;
- texel[i][GCOMP] = ambient;
- texel[i][BCOMP] = ambient;
- texel[i][ACOMP] = CHAN_MAX;
+ result = ambient;
}
else {
- texel[i][RCOMP] = CHAN_MAX;
- texel[i][GCOMP] = CHAN_MAX;
- texel[i][BCOMP] = CHAN_MAX;
- texel[i][ACOMP] = CHAN_MAX;
+ result = CHAN_MAX;
}
}
else {
*/
const GLfloat d = (CHAN_MAXF - (GLfloat) ambient) * 0.25F;
GLfloat luminance = CHAN_MAXF;
- GLchan lum;
if (lequal) {
if (depth00 <= r[i]) luminance -= d;
if (depth01 <= r[i]) luminance -= d;
if (depth10 >= r[i]) luminance -= d;
if (depth11 >= r[i]) luminance -= d;
}
- lum = (GLchan) luminance;
- texel[i][RCOMP] = lum;
- texel[i][GCOMP] = lum;
- texel[i][BCOMP] = lum;
+ result = (GLchan) luminance;
+ }
+
+ switch (texObj->CompareResult) {
+ case GL_LUMINANCE:
+ texel[i][RCOMP] = result;
+ texel[i][GCOMP] = result;
+ texel[i][BCOMP] = result;
texel[i][ACOMP] = CHAN_MAX;
+ break;
+ case GL_INTENSITY:
+ texel[i][RCOMP] = result;
+ texel[i][GCOMP] = result;
+ texel[i][BCOMP] = result;
+ texel[i][ACOMP] = result;
+ break;
+ case GL_ALPHA:
+ texel[i][RCOMP] = 0;
+ texel[i][GCOMP] = 0;
+ texel[i][BCOMP] = 0;
+ texel[i][ACOMP] = result;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad texture compare result value");
}
- }
- }
+ } /* for */
+ } /* if filter */
}
const struct gl_texture_unit *textureUnit = &ctx->Texture.Unit[texUnit];
if (textureUnit->_Current) { /* XXX need this? */
+ const struct gl_texture_object *curObj = textureUnit->_Current;
GLchan texel[PB_SIZE][4];
if (textureUnit->LodBias != 0.0F) {
}
}
- if ((textureUnit->_Current->MinLod != -1000.0
- || textureUnit->_Current->MaxLod != 1000.0)
+ if ((curObj->MinLod != -1000.0 || curObj->MaxLod != 1000.0)
&& lambda) {
/* apply LOD clamping to lambda */
- const GLfloat min = textureUnit->_Current->MinLod;
- const GLfloat max = textureUnit->_Current->MaxLod;
+ const GLfloat min = curObj->MinLod;
+ const GLfloat max = curObj->MaxLod;
GLuint i;
for (i=0;i<n;i++) {
GLfloat l = lambda[i];
}
/* Sample the texture. */
- if (textureUnit->_Current->CompareFlag) {
+ if (curObj->Image[curObj->BaseLevel]->Format == GL_DEPTH_COMPONENT) {
/* depth texture */
sample_depth_texture(ctx, textureUnit, n, s, t, r, texel);
}