summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/attrib.c5
-rw-r--r--src/mesa/main/enums.c5
-rw-r--r--src/mesa/main/extensions.c6
-rw-r--r--src/mesa/main/mtypes.h4
-rw-r--r--src/mesa/main/texstate.c120
-rw-r--r--src/mesa/swrast/s_texture.c34
6 files changed, 130 insertions, 44 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index e856dc1f44..0acb2a9597 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.48 2001/04/11 23:22:20 brianp Exp $ */
+/* $Id: attrib.c,v 1.49 2001/04/17 21:25:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -602,7 +602,8 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
_mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
GL_TEXTURE_LOD_BIAS_EXT, unit->LodBias);
}
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT,
unit->CombineModeRGB);
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT,
diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c
index 7b6dd53f02..8510ce8105 100644
--- a/src/mesa/main/enums.c
+++ b/src/mesa/main/enums.c
@@ -1,4 +1,4 @@
-/* $Id: enums.c,v 1.17 2001/04/16 21:07:33 brianp Exp $ */
+/* $Id: enums.c,v 1.18 2001/04/17 21:25:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -833,6 +833,9 @@ enum_elt all_enums[] =
{ "GL_PRIMARY_COLOR_EXT", 0x8577 },
{ "GL_PREVIOUS_EXT", 0x8578 },
+ /* GL_ARB_texture_env_combine */
+ { "GL_SUBTRACT_ARB", 0x84E7 },
+
/* GL_EXT_texture_env_dot3 */
{ "GL_DOT3_RGB_EXT", 0x8740 },
{ "GL_DOT3_RGBA_EXT", 0x8741 },
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 372b2bb687..2c54d0edaf 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -1,4 +1,4 @@
-/* $Id: extensions.c,v 1.56 2001/03/26 19:42:40 brianp Exp $ */
+/* $Id: extensions.c,v 1.57 2001/04/17 21:25:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -62,8 +62,8 @@ static struct {
{ OFF, "GL_ARB_texture_compression", F(ARB_texture_compression) },
{ OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) },
{ OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) },
- { OFF, "GL_ARB_texture_env_combine", F(EXT_texture_env_combine) },
- { OFF, "GL_ARB_texture_env_dot3", F(EXT_texture_env_dot3) },
+ { OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) },
+ { OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) },
{ ON, "GL_ARB_tranpose_matrix", 0 },
{ ON, "GL_EXT_abgr", 0 },
{ ON, "GL_EXT_bgra", 0 },
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8113a243d4..42a8b28c58 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.38 2001/03/29 21:16:25 keithw Exp $ */
+/* $Id: mtypes.h,v 1.39 2001/04/17 21:25:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1173,6 +1173,8 @@ struct gl_extensions {
GLboolean ARB_texture_border_clamp;
GLboolean ARB_texture_compression;
GLboolean ARB_texture_cube_map;
+ GLboolean ARB_texture_env_combine;
+ GLboolean ARB_texture_env_dot3;
GLboolean EXT_blend_color;
GLboolean EXT_blend_func_separate;
GLboolean EXT_blend_logic_op;
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index a52d3ef862..3770df3898 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.43 2001/04/16 21:06:54 brianp Exp $ */
+/* $Id: texstate.c,v 1.44 2001/04/17 21:25:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -68,6 +68,10 @@
#define GL_CLAMP_TO_BORDER_ARB 0x812D
#endif
+#ifndef GL_SUBTRACT_ARB
+#define GL_SUBTRACT_ARB 0x84E7
+#endif
+
/**********************************************************************/
/* Texture Environment */
@@ -101,7 +105,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
}
break;
case GL_COMBINE_EXT:
- if (!ctx->Extensions.EXT_texture_env_combine) {
+ if (!ctx->Extensions.EXT_texture_env_combine &&
+ !ctx->Extensions.ARB_texture_env_combine) {
ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
return;
}
@@ -135,20 +140,33 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
break;
}
case GL_COMBINE_RGB_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
- GLenum mode = (GLenum) (GLint) *param;
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ const GLenum mode = (GLenum) (GLint) *param;
switch (mode) {
case GL_REPLACE:
case GL_MODULATE:
case GL_ADD:
case GL_ADD_SIGNED_EXT:
case GL_INTERPOLATE_EXT:
+ /* OK */
break;
+ case GL_SUBTRACT_ARB:
+ if (!ctx->Extensions.ARB_texture_env_combine) {
+ ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
+ return;
+ }
+ break;
case GL_DOT3_RGB_EXT:
case GL_DOT3_RGBA_EXT:
+ if (!ctx->Extensions.EXT_texture_env_dot3) {
+ ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
+ return;
+ }
+ break;
case GL_DOT3_RGB_ARB:
case GL_DOT3_RGBA_ARB:
- if (!ctx->Extensions.EXT_texture_env_dot3) {
+ if (!ctx->Extensions.ARB_texture_env_dot3) {
ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
return;
}
@@ -168,23 +186,31 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
}
break;
case GL_COMBINE_ALPHA_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
- GLenum mode = (GLenum) (GLint) *param;
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ const GLenum mode = (GLenum) (GLint) *param;
switch (mode) {
case GL_REPLACE:
case GL_MODULATE:
case GL_ADD:
case GL_ADD_SIGNED_EXT:
case GL_INTERPOLATE_EXT:
- if (texUnit->CombineModeA == mode)
- return;
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->CombineModeA = mode;
+ /* OK */
break;
+ case GL_SUBTRACT_ARB:
+ if (!ctx->Extensions.ARB_texture_env_combine) {
+ ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
+ return;
+ }
+ break;
default:
ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
return;
}
+ if (texUnit->CombineModeA == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->CombineModeA = mode;
}
else {
ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
@@ -194,7 +220,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
case GL_SOURCE0_RGB_EXT:
case GL_SOURCE1_RGB_EXT:
case GL_SOURCE2_RGB_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
GLenum source = (GLenum) (GLint) *param;
GLuint s = pname - GL_SOURCE0_RGB_EXT;
switch (source) {
@@ -220,7 +247,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
case GL_SOURCE0_ALPHA_EXT:
case GL_SOURCE1_ALPHA_EXT:
case GL_SOURCE2_ALPHA_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
GLenum source = (GLenum) (GLint) *param;
GLuint s = pname - GL_SOURCE0_ALPHA_EXT;
switch (source) {
@@ -244,7 +272,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
break;
case GL_OPERAND0_RGB_EXT:
case GL_OPERAND1_RGB_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
GLenum operand = (GLenum) (GLint) *param;
GLuint s = pname - GL_OPERAND0_RGB_EXT;
switch (operand) {
@@ -269,7 +298,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
break;
case GL_OPERAND0_ALPHA_EXT:
case GL_OPERAND1_ALPHA_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
GLenum operand = (GLenum) (GLint) *param;
switch (operand) {
case GL_SRC_ALPHA:
@@ -291,7 +321,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
}
break;
case GL_OPERAND2_RGB_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
GLenum operand = (GLenum) (GLint) *param;
switch (operand) {
case GL_SRC_COLOR: /* ARB combine only */
@@ -313,7 +344,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
}
break;
case GL_OPERAND2_ALPHA_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
GLenum operand = (GLenum) (GLint) *param;
switch (operand) {
case GL_SRC_ALPHA:
@@ -334,7 +366,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
}
break;
case GL_RGB_SCALE_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
GLuint newshift;
if (*param == 1.0) {
newshift = 0;
@@ -361,7 +394,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
}
break;
case GL_ALPHA_SCALE:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
GLuint newshift;
if (*param == 1.0) {
newshift = 0;
@@ -478,7 +512,8 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
COPY_4FV( params, texUnit->EnvColor );
break;
case GL_RGB_SCALE_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
if (texUnit->CombineScaleShiftRGB == 0)
*params = 1.0;
else if (texUnit->CombineScaleShiftRGB == 1)
@@ -492,7 +527,8 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
}
break;
case GL_ALPHA_SCALE:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
if (texUnit->CombineScaleShiftA == 0)
*params = 1.0;
else if (texUnit->CombineScaleShiftA == 1)
@@ -534,7 +570,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] );
break;
case GL_COMBINE_RGB_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineModeRGB;
}
else {
@@ -542,7 +579,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_COMBINE_ALPHA_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineModeA;
}
else {
@@ -550,7 +588,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_SOURCE0_RGB_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineSourceRGB[0];
}
else {
@@ -558,7 +597,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_SOURCE1_RGB_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineSourceRGB[1];
}
else {
@@ -566,7 +606,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_SOURCE2_RGB_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineSourceRGB[2];
}
else {
@@ -574,7 +615,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_SOURCE0_ALPHA_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineSourceA[0];
}
else {
@@ -582,7 +624,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_SOURCE1_ALPHA_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineSourceA[1];
}
else {
@@ -590,7 +633,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_SOURCE2_ALPHA_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineSourceA[2];
}
else {
@@ -598,7 +642,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_OPERAND0_RGB_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineOperandRGB[0];
}
else {
@@ -606,7 +651,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_OPERAND1_RGB_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineOperandRGB[1];
}
else {
@@ -614,7 +660,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_OPERAND2_RGB_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineOperandRGB[2];
}
else {
@@ -622,7 +669,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_OPERAND0_ALPHA_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineOperandA[0];
}
else {
@@ -630,7 +678,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_OPERAND1_ALPHA_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineOperandA[1];
}
else {
@@ -638,7 +687,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
break;
case GL_OPERAND2_ALPHA_EXT:
- if (ctx->Extensions.EXT_texture_env_combine) {
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
*params = (GLint) texUnit->CombineOperandA[2];
}
else {
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 7f932f8b13..78c38c07fd 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.23 2001/04/12 15:18:07 brianp Exp $ */
+/* $Id: s_texture.c,v 1.24 2001/04/17 21:25:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -52,6 +52,10 @@
#define GL_CLAMP_TO_BORDER_ARB 0x812D
#endif
+#ifndef GL_SUBTRACT_ARB
+#define GL_SUBTRACT_ARB 0x84E7
+#endif
+
/*
* These values are used in the fixed-point arithmetic used
@@ -1763,7 +1767,8 @@ texture_combine(const GLcontext *ctx,
const GLuint RGBshift = textureUnit->CombineScaleShiftRGB;
const GLuint Ashift = textureUnit->CombineScaleShiftA;
- ASSERT(ctx->Extensions.EXT_texture_env_combine);
+ ASSERT(ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine);
/*
* Do operand setup for up to 3 operands. Loop over the terms.
@@ -1968,6 +1973,20 @@ texture_combine(const GLcontext *ctx,
}
}
break;
+ case GL_SUBTRACT_ARB:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1];
+ for (i = 0; i < n; i++) {
+ GLint r = ((GLint) arg0[i][RCOMP] - (GLint) arg1[i][RCOMP]) << RGBshift;
+ GLint g = ((GLint) arg0[i][GCOMP] - (GLint) arg1[i][GCOMP]) << RGBshift;
+ GLint b = ((GLint) arg0[i][BCOMP] - (GLint) arg1[i][BCOMP]) << RGBshift;
+ rgba[i][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX);
+ rgba[i][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX);
+ rgba[i][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX);
+ }
+ }
+ break;
case GL_DOT3_RGB_EXT:
case GL_DOT3_RGBA_EXT:
case GL_DOT3_RGB_ARB:
@@ -2059,6 +2078,17 @@ texture_combine(const GLcontext *ctx,
}
}
break;
+ case GL_SUBTRACT_ARB:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1];
+ for (i = 0; i < n; i++) {
+ GLint a = ((GLint) arg0[i][ACOMP] - (GLint) arg1[i][ACOMP]) << RGBshift;
+ rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
+ }
+ }
+ break;
+
default:
_mesa_problem(NULL, "invalid combine mode");
}