fixed 16 bit/channel problem in blend_modulate()
authorBrian Paul <brian.paul@tungstengraphics.com>
Thu, 4 Apr 2002 16:53:26 +0000 (16:53 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Thu, 4 Apr 2002 16:53:26 +0000 (16:53 +0000)
src/mesa/swrast/s_blend.c

index 73c03d1a63483240d1439ab45df0969e45c883f5..3fdb808abf0d1c6d715e63dc4b19d1f611c4cbfb 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: s_blend.c,v 1.17 2002/04/04 01:40:18 brianp Exp $ */
+/* $Id: s_blend.c,v 1.18 2002/04/04 16:53:26 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -274,11 +274,20 @@ blend_modulate( GLcontext *ctx, GLuint n, const GLubyte mask[],
          rgba[i][GCOMP] = rgba[i][GCOMP] * dest[i][GCOMP];
          rgba[i][BCOMP] = rgba[i][BCOMP] * dest[i][BCOMP];
          rgba[i][ACOMP] = rgba[i][ACOMP] * dest[i][ACOMP];
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+         GLint r = (rgba[i][RCOMP] * dest[i][RCOMP] + 65535) >> 16;
+         GLint g = (rgba[i][GCOMP] * dest[i][GCOMP] + 65535) >> 16;
+         GLint b = (rgba[i][BCOMP] * dest[i][BCOMP] + 65535) >> 16;
+         GLint a = (rgba[i][ACOMP] * dest[i][ACOMP] + 65535) >> 16;
+         rgba[i][RCOMP] = (GLchan) r;
+         rgba[i][GCOMP] = (GLchan) g;
+         rgba[i][BCOMP] = (GLchan) b;
+         rgba[i][ACOMP] = (GLchan) a;
 #else
-         GLint r = (rgba[i][RCOMP] * dest[i][RCOMP]) >> 8;
-         GLint g = (rgba[i][GCOMP] * dest[i][GCOMP]) >> 8;
-         GLint b = (rgba[i][BCOMP] * dest[i][BCOMP]) >> 8;
-         GLint a = (rgba[i][ACOMP] * dest[i][ACOMP]) >> 8;
+         GLint r = (rgba[i][RCOMP] * dest[i][RCOMP] + 255) >> 8;
+         GLint g = (rgba[i][GCOMP] * dest[i][GCOMP] + 255) >> 8;
+         GLint b = (rgba[i][BCOMP] * dest[i][BCOMP] + 255) >> 8;
+         GLint a = (rgba[i][ACOMP] * dest[i][ACOMP] + 255) >> 8;
          rgba[i][RCOMP] = (GLchan) r;
          rgba[i][GCOMP] = (GLchan) g;
          rgba[i][BCOMP] = (GLchan) b;