summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/teximage.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index a5d3ef97a57..0f6bde4bb01 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1,4 +1,4 @@
-/* $Id: teximage.c,v 1.7 1999/10/21 12:45:03 brianp Exp $ */
+/* $Id: teximage.c,v 1.8 1999/10/22 10:43:35 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1674,7 +1674,7 @@ void gl_TexSubImage2D( GLcontext *ctx,
/* row by row. */
GLubyte *dst = destTex->Data
+ (yoffsetb * destTex->Width + xoffsetb) * texcomponents;
- GLubyte *src = (GLubyte *) image->Data;
+ const GLubyte *src = (const GLubyte *) image->Data;
GLint j;
for (j=0;j<height;j++) {
MEMCPY( dst, src, width * texcomponents );
@@ -1682,13 +1682,32 @@ void gl_TexSubImage2D( GLcontext *ctx,
src += width * texcomponents * sizeof(GLubyte);
}
}
+ else if (image->Type==GL_UNSIGNED_BYTE
+ && texcomponents==3 && image->Components == 4 ) {
+ /* 32 bit (padded) to 24 bit case, used heavily by quake */
+ GLubyte *dst = destTex->Data
+ + (yoffsetb * destTex->Width + xoffsetb) * texcomponents;
+ const GLubyte *src = (const GLubyte *) image->Data;
+ GLint j;
+ for (j=0;j<height;j++) {
+ const GLubyte *stop = src + (width << 2);
+ for ( ; src != stop ; ) {
+ dst[0] = src[0];
+ dst[1] = src[1];
+ dst[2] = src[2];
+ dst += 3;
+ src += 4;
+ }
+ dst += (destTex->Width - width) * texcomponents * sizeof(GLubyte);
+ }
+ }
else {
/* General case, convert image pixels into texels, scale, bias, etc */
struct gl_texture_image *subTexImg = image_to_texture(ctx, image,
destTex->IntFormat, destTex->Border);
GLubyte *dst = destTex->Data
+ (yoffsetb * destTex->Width + xoffsetb) * texcomponents;
- GLubyte *src = subTexImg->Data;
+ const GLubyte *src = subTexImg->Data;
GLint j;
for (j=0;j<height;j++) {
MEMCPY( dst, src, width * texcomponents );