diff options
author | Brian Paul <[email protected]> | 2002-04-12 21:17:28 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2002-04-12 21:17:28 +0000 |
commit | 8c598cfd8280357de7777019afa2a3d6ae0a7781 (patch) | |
tree | 0882d9138386bf5fb7fb207a07bc69549596f0d4 /src | |
parent | cb445412fc57a9622d75cb3bf09c3477f9e2c1b0 (diff) |
fixes for corrected GL_DOT3_RGB[A]_EXT token values
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/texstate.c | 12 | ||||
-rw-r--r-- | src/mesa/swrast/s_texture.c | 39 |
2 files changed, 41 insertions, 10 deletions
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 3eadc53e735..a6d6d827ab1 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -1,4 +1,4 @@ -/* $Id: texstate.c,v 1.66 2002/03/23 16:33:53 brianp Exp $ */ +/* $Id: texstate.c,v 1.67 2002/04/12 21:17:28 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -140,10 +140,16 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) return; } break; + case GL_DOT3_RGB_EXT: + case GL_DOT3_RGBA_EXT: + if (!ctx->Extensions.EXT_texture_env_dot3) { + TE_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 && - !ctx->Extensions.ARB_texture_env_dot3) { + if (!ctx->Extensions.ARB_texture_env_dot3) { TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); return; } diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index 060c8e136d8..f5f4bb5d632 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.59 2002/04/12 15:39:59 brianp Exp $ */ +/* $Id: s_texture.c,v 1.60 2002/04/12 21:17:28 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -2813,15 +2813,37 @@ texture_combine(const GLcontext *ctx, } } break; + case GL_DOT3_RGB_EXT: + case GL_DOT3_RGBA_EXT: + { + /* Do not scale the result by 1 2 or 4 */ + const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; + const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; + for (i = 0; i < n; i++) { +#if CHAN_TYPE == GL_FLOAT + GLchan dot = ((arg0[i][RCOMP]-0.5F) * (arg1[i][RCOMP]-0.5F) + + (arg0[i][GCOMP]-0.5F) * (arg1[i][GCOMP]-0.5F) + + (arg0[i][BCOMP]-0.5F) * (arg1[i][BCOMP]-0.5F)) + * 4.0F; +#else + GLint dot = (S_PROD((GLint)arg0[i][RCOMP] - half, + (GLint)arg1[i][RCOMP] - half) + + S_PROD((GLint)arg0[i][GCOMP] - half, + (GLint)arg1[i][GCOMP] - half) + + S_PROD((GLint)arg0[i][BCOMP] - half, + (GLint)arg1[i][BCOMP] - half)) >> 6; +#endif + dot = CLAMP(dot, 0, CHAN_MAX); + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = (GLchan) dot; + } + } + break; case GL_DOT3_RGB_ARB: case GL_DOT3_RGBA_ARB: { + /* DO scale the result by 1 2 or 4 */ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; const GLchan (*arg1)[4] = (const GLchan (*)[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++) { #if CHAN_TYPE == GL_FLOAT GLchan dot = ((arg0[i][RCOMP]-0.5F) * (arg1[i][RCOMP]-0.5F) + @@ -2836,7 +2858,7 @@ texture_combine(const GLcontext *ctx, S_PROD((GLint)arg0[i][BCOMP] - half, (GLint)arg1[i][BCOMP] - half)) >> 6; #endif - dot = CLAMP(dot, 0, CHAN_MAX); + dot = CLAMP(dot, 0, CHAN_MAX) << RGBshift; rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = (GLchan) dot; } } @@ -2953,7 +2975,10 @@ texture_combine(const GLcontext *ctx, _mesa_problem(ctx, "invalid combine mode"); } - /* Fix the alpha component for GL_DOT3_RGBA_EXT combining. + /* Fix the alpha component for GL_DOT3_RGBA_EXT/ARB combining. + * This is kind of a kludge. It would have been better if the spec + * were written such that the GL_COMBINE_ALPHA value could be set to + * GL_DOT3. */ if (textureUnit->CombineModeRGB == GL_DOT3_RGBA_EXT || textureUnit->CombineModeRGB == GL_DOT3_RGBA_ARB) { |