From e201bef913bbb869e9c4012fcfff2406e9d55393 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 30 Jun 2002 15:57:45 +0000 Subject: [PATCH] blending fixes for CHAN_TYPE==GL_FLOAT (Gerk Huisma) --- src/mesa/swrast/s_blend.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/mesa/swrast/s_blend.c b/src/mesa/swrast/s_blend.c index 73e7de5c31d..8397d876a20 100644 --- a/src/mesa/swrast/s_blend.c +++ b/src/mesa/swrast/s_blend.c @@ -1,4 +1,4 @@ -/* $Id: s_blend.c,v 1.22 2002/04/19 20:12:31 jrfonseca Exp $ */ +/* $Id: s_blend.c,v 1.23 2002/06/30 15:57:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -318,8 +318,13 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], for (i=0;iColor.BlendEquation==GL_FUNC_ADD_EXT) { + r = Rs * sR + Rd * dR; + g = Gs * sG + Gd * dG; + b = Bs * sB + Bd * dB; + a = As * sA + Ad * dA; + } + else if (ctx->Color.BlendEquation==GL_FUNC_SUBTRACT_EXT) { + r = Rs * sR - Rd * dR; + g = Gs * sG - Gd * dG; + b = Bs * sB - Bd * dB; + a = As * sA - Ad * dA; + } + else if (ctx->Color.BlendEquation==GL_FUNC_REVERSE_SUBTRACT_EXT) { + r = Rd * dR - Rs * sR; + g = Gd * dG - Gs * sG; + b = Bd * dB - Bs * sB; + a = Ad * dA - As * sA; + } + else { + /* should never get here */ + r = g = b = a = 0.0F; /* silence uninitialized var warning */ + _mesa_problem(ctx, "unexpected BlendEquation in blend_general()"); + } + + /* final clamping */ + rgba[i][RCOMP] = CLAMP( r, 0.0F, CHAN_MAXF ); + rgba[i][GCOMP] = CLAMP( g, 0.0F, CHAN_MAXF ); + rgba[i][BCOMP] = CLAMP( b, 0.0F, CHAN_MAXF ); + rgba[i][ACOMP] = CLAMP( a, 0.0F, CHAN_MAXF ); +#else if (ctx->Color.BlendEquation==GL_FUNC_ADD_EXT) { r = Rs * sR + Rd * dR + 0.5F; g = Gs * sG + Gd * dG + 0.5F; @@ -622,6 +658,7 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], rgba[i][GCOMP] = (GLchan) (GLint) CLAMP( g, 0.0F, CHAN_MAXF ); rgba[i][BCOMP] = (GLchan) (GLint) CLAMP( b, 0.0F, CHAN_MAXF ); rgba[i][ACOMP] = (GLchan) (GLint) CLAMP( a, 0.0F, CHAN_MAXF ); +#endif } } } -- 2.30.2