summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-04-13 00:13:51 +0000
committerBrian Paul <[email protected]>2001-04-13 00:13:51 +0000
commitbf478280ebed8a60a5d007884d9817391e206987 (patch)
treee23440b4d7ab7fd98adba9c1c33257ab875e4271
parent77ff5e038a141317e4db6eb4fb7262320052a55f (diff)
added a work-around in _swrast_copy_texsubimage[123]d() to fix alpha channel problem in some DRI drivers (see comments)
-rw-r--r--src/mesa/swrast/s_texstore.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/mesa/swrast/s_texstore.c b/src/mesa/swrast/s_texstore.c
index 92afecf91db..f01dab5fdd3 100644
--- a/src/mesa/swrast/s_texstore.c
+++ b/src/mesa/swrast/s_texstore.c
@@ -1,4 +1,4 @@
-/* $Id: s_texstore.c,v 1.2 2001/03/28 20:40:52 gareth Exp $ */
+/* $Id: s_texstore.c,v 1.3 2001/04/13 00:13:51 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -274,6 +274,22 @@ _swrast_copy_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
return;
}
+ /*
+ * XXX this is a bit of a hack. We need to be sure that the alpha
+ * channel is 1.0 if the internal texture format is not supposed to
+ * have an alpha channel. This is because some drivers may store
+ * RGB textures as RGBA and the texutil.c code isn't smart enough
+ * to set the alpha channel to 1.0 in this situation.
+ */
+ if (texImage->Format == GL_LUMINANCE ||
+ texImage->Format == GL_RGB) {
+ const GLuint n = width * 4;
+ GLuint i;
+ for (i = 0; i < n; i += 4) {
+ image[i + 3] = CHAN_MAX;
+ }
+ }
+
/* now call glTexSubImage1D to do the real work */
(*ctx->Driver.TexSubImage1D)(ctx, target, level, xoffset, width,
GL_RGBA, CHAN_TYPE, image,
@@ -326,6 +342,22 @@ _swrast_copy_texsubimage2d( GLcontext *ctx,
return;
}
+ /*
+ * XXX this is a bit of a hack. We need to be sure that the alpha
+ * channel is 1.0 if the internal texture format is not supposed to
+ * have an alpha channel. This is because some drivers may store
+ * RGB textures as RGBA and the texutil.c code isn't smart enough
+ * to set the alpha channel to 1.0 in this situation.
+ */
+ if (texImage->Format == GL_LUMINANCE ||
+ texImage->Format == GL_RGB) {
+ const GLuint n = width * height * 4;
+ GLuint i;
+ for (i = 0; i < n; i += 4) {
+ image[i + 3] = CHAN_MAX;
+ }
+ }
+
/* now call glTexSubImage2D to do the real work */
(*ctx->Driver.TexSubImage2D)(ctx, target, level,
xoffset, yoffset, width, height,
@@ -380,6 +412,22 @@ _swrast_copy_texsubimage3d( GLcontext *ctx,
return;
}
+ /*
+ * XXX this is a bit of a hack. We need to be sure that the alpha
+ * channel is 1.0 if the internal texture format is not supposed to
+ * have an alpha channel. This is because some drivers may store
+ * RGB textures as RGBA and the texutil.c code isn't smart enough
+ * to set the alpha channel to 1.0 in this situation.
+ */
+ if (texImage->Format == GL_LUMINANCE ||
+ texImage->Format == GL_RGB) {
+ const GLuint n = width * height * 4;
+ GLuint i;
+ for (i = 0; i < n; i += 4) {
+ image[i + 3] = CHAN_MAX;
+ }
+ }
+
/* now call glTexSubImage3D to do the real work */
(*ctx->Driver.TexSubImage3D)(ctx, target, level,
xoffset, yoffset, zoffset, width, height, 1,