Implementation of GL_EXT_texture_env_dot3.

This commit is contained in:
Gareth Hughes 2001-01-06 22:46:13 +00:00
parent c851646050
commit ba8f6172bd
7 changed files with 131 additions and 68 deletions

View File

@ -1,4 +1,4 @@
/* $Id: gl.h,v 1.49 2000/12/09 20:36:18 brianp Exp $ */
/* $Id: gl.h,v 1.50 2001/01/06 22:46:13 gareth Exp $ */
/*
* Mesa 3-D graphics library
@ -2228,6 +2228,19 @@ GLAPI void GLAPIENTRY glResizeBuffersMESA( void );
#endif /* GL_MESA_resize_bufffers */
/*
* 220. GL_EXT_texture_env_dot3
*/
#ifndef GL_EXT_texture_env_dot3
#define GL_EXT_texture_env_dot3 1
#define GL_DOT3_RGB_EXT 0x8740
#define GL_DOT3_RGBA_EXT 0x8741
#endif /* GL_EXT_texture_env_dot3 */
#else /* GL_GLEXT_LEGACY */
#include <GL/glext.h>

View File

@ -1419,6 +1419,11 @@ extern "C" {
#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF
#endif
#ifndef GL_EXT_texture_env_dot3
#define GL_DOT3_RGB_EXT 0x8740
#define GL_DOT3_RGBA_EXT 0x8741
#endif
/*************************************************************/

View File

@ -1,4 +1,4 @@
/* $Id: enums.c,v 1.9 2000/06/27 21:42:13 brianp Exp $ */
/* $Id: enums.c,v 1.10 2001/01/06 22:46:13 gareth Exp $ */
/*
* Mesa 3-D graphics library
@ -828,7 +828,11 @@ enum_elt all_enums[] =
{ "GL_INTERPOLATE_EXT", 0x8575 },
{ "GL_CONSTANT_EXT", 0x8576 },
{ "GL_PRIMARY_COLOR_EXT", 0x8577 },
{ "GL_PREVIOUS_EXT", 0x8578 }
{ "GL_PREVIOUS_EXT", 0x8578 },
/* GL_EXT_texture_env_dot3 */
{ "GL_DOT3_RGB_EXT", 0x8740 },
{ "GL_DOT3_RGBA_EXT", 0x8741 },
};

View File

@ -1,4 +1,4 @@
/* $Id: extensions.c,v 1.43 2000/12/08 00:20:15 brianp Exp $ */
/* $Id: extensions.c,v 1.44 2001/01/06 22:46:13 gareth Exp $ */
/*
* Mesa 3-D graphics library
@ -87,6 +87,7 @@ static struct {
{ OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) },
{ ON, "GL_EXT_texture_env_add", F(EXT_texture_env_add) },
{ OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) },
{ OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) },
{ ON, "GL_EXT_texture_object", F(EXT_texture_object) },
{ ON, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) },
{ ON, "GL_EXT_vertex_array", 0 },
@ -120,6 +121,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
gl_extensions_enable(ctx, "GL_ARB_texture_cube_map");
gl_extensions_enable(ctx, "GL_EXT_bgra");
gl_extensions_enable(ctx, "GL_EXT_texture_env_combine");
gl_extensions_enable(ctx, "GL_EXT_texture_env_dot3");
gl_extensions_enable(ctx, "GL_HP_occlusion_test");
gl_extensions_enable(ctx, "GL_NV_blend_square");
gl_extensions_enable(ctx, "GL_MESA_sprite_point");

View File

@ -1,4 +1,4 @@
/* $Id: mtypes.h,v 1.10 2001/01/05 02:26:48 keithw Exp $ */
/* $Id: mtypes.h,v 1.11 2001/01/06 22:46:13 gareth Exp $ */
/*
* Mesa 3-D graphics library
@ -1231,6 +1231,7 @@ struct gl_extensions {
GLboolean EXT_texture_compression_s3tc;
GLboolean EXT_texture_env_add;
GLboolean EXT_texture_env_combine;
GLboolean EXT_texture_env_dot3;
GLboolean EXT_texture_object;
GLboolean EXT_texture_lod_bias;
GLboolean EXT_vertex_array_set;

View File

@ -1,4 +1,4 @@
/* $Id: texstate.c,v 1.26 2000/12/26 05:09:29 keithw Exp $ */
/* $Id: texstate.c,v 1.27 2001/01/06 22:46:13 gareth Exp $ */
/*
* Mesa 3-D graphics library
@ -127,6 +127,13 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
case GL_ADD_SIGNED_EXT:
case GL_INTERPOLATE_EXT:
break;
case GL_DOT3_RGB_EXT:
case GL_DOT3_RGBA_EXT:
if (!ctx->Extensions.EXT_texture_env_dot3) {
gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
return;
}
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
return;

View File

@ -1,4 +1,4 @@
/* $Id: s_texture.c,v 1.7 2001/01/05 21:28:31 brianp Exp $ */
/* $Id: s_texture.c,v 1.8 2001/01/06 22:46:13 gareth Exp $ */
/*
* Mesa 3-D graphics library
@ -1830,6 +1830,7 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
#define PROD(A,B) ( (GLuint)(A) * ((GLuint)(B)+1) )
#define S_PROD(A,B) ( (GLint)(A) * ((GLint)(B)+1) )
static INLINE void
_mesa_texture_combine(const GLcontext *ctx,
@ -2044,6 +2045,28 @@ _mesa_texture_combine(const GLcontext *ctx,
}
}
break;
case GL_DOT3_RGB_EXT:
case GL_DOT3_RGBA_EXT:
{
const GLubyte (*arg0)[4] = (const GLubyte (*)[4]) argRGB[0];
const GLubyte (*arg1)[4] = (const GLubyte (*)[4]) argRGB[1];
/* ATI's EXT extension has a constant scale by 4. The ARB
* one will likely remove this restriction, and we should
* drop the EXT extension in favour of the ARB one.
*/
for (i = 0; i < n; i++) {
GLint dot = (S_PROD((GLint)arg0[i][RCOMP] - 128,
(GLint)arg1[i][RCOMP] - 128) +
S_PROD((GLint)arg0[i][GCOMP] - 128,
(GLint)arg1[i][GCOMP] - 128) +
S_PROD((GLint)arg0[i][BCOMP] - 128,
(GLint)arg1[i][BCOMP] - 128)) >> 6;
rgba[i][RCOMP] = (GLubyte) CLAMP(dot, 0, 255);
rgba[i][GCOMP] = (GLubyte) CLAMP(dot, 0, 255);
rgba[i][BCOMP] = (GLubyte) CLAMP(dot, 0, 255);
}
}
break;
default:
gl_problem(NULL, "invalid combine mode");
}
@ -2114,6 +2137,14 @@ _mesa_texture_combine(const GLcontext *ctx,
default:
gl_problem(NULL, "invalid combine mode");
}
/* Fix the alpha component for GL_DOT3_RGBA_EXT combining.
*/
if (textureUnit->CombineModeRGB == GL_DOT3_RGBA_EXT) {
for (i = 0; i < n; i++) {
rgba[i][ACOMP] = rgba[i][RCOMP];
}
}
}
#undef PROD