diff --git a/r_draw.c b/r_draw.c index 96005f83..26f9cbe9 100644 --- a/r_draw.c +++ b/r_draw.c @@ -70,6 +70,8 @@ void R_DrawStretchPicImplementation (int x, int y, int w, int h, int s1, int t1, unsigned int height; unsigned int f, fstep; int skip; + qboolean transparent = false; + pixel_t *buffer; if( x < 0 ) { @@ -104,6 +106,14 @@ void R_DrawStretchPicImplementation (int x, int y, int w, int h, int s1, int t1, dest = vid.buffer + y * vid.rowbytes + x; + if( pic->alpha_pixels ) + { + buffer = pic->alpha_pixels; + transparent = true; + } + else + buffer = pic->pixels[0]; + #pragma omp parallel for schedule(static) for (v=0 ; vpixels[0] + sv*pic->width + s1; + source = buffer + sv*pic->width + s1; { f = 0; fstep = s2*0x10000/w; @@ -137,7 +147,7 @@ void R_DrawStretchPicImplementation (int x, int y, int w, int h, int s1, int t1, int alpha = vid.alpha; f += fstep; - if( pic->transparent ) + if( transparent ) { alpha &= src >> 16 - 3; src = src << 3; diff --git a/r_image.c b/r_image.c index 5ae2e48f..200b4eb7 100644 --- a/r_image.c +++ b/r_image.c @@ -530,9 +530,9 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic ) size = GL_CalcImageSize( pic->type, width, height, tex->depth ); //GL_TextureImageRAW( tex, i, j, width, height, tex->depth, pic->type, data ); tex->pixels[j] = Mem_Calloc( r_temppool, width * height * sizeof(pixel_t) + 64 ); + if( j == 0 && tex->flags & TF_HAS_ALPHA ) + tex->alpha_pixels = Mem_Calloc( r_temppool, width * height * sizeof(pixel_t) + 64 ); int x, y; - if( tex->flags & TF_HAS_ALPHA ) - tex->transparent = true; for(i = 0; i < height * width; i++ ) { @@ -554,10 +554,10 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic ) minor = MOVE_BIT(r,1,5) | MOVE_BIT(r,0,2) | MOVE_BIT(g,2,7) | MOVE_BIT(g,1,4) | MOVE_BIT(g,0,1) | MOVE_BIT(b,2,6)| MOVE_BIT(b,1,3)|MOVE_BIT(b,0,0); tex->pixels[j][i] = major << 8 | (minor & 0xFF); - if( tex->transparent ) + if( j == 0 && tex->alpha_pixels ) { unsigned int alpha = (pic->buffer[i * 4 + 3] * 8 / 256) << (16 - 3); - tex->pixels[j][i] = (tex->pixels[j][i] >> 3) | alpha; + tex->alpha_pixels[i] = (tex->pixels[j][i] >> 3) | alpha; } } diff --git a/r_local.h b/r_local.h index 4eb47a99..932f3aa7 100644 --- a/r_local.h +++ b/r_local.h @@ -358,8 +358,9 @@ typedef struct image_s float yscale; imagetype_t type; - qboolean transparent; pixel_t *pixels[4]; // mip levels + pixel_t *alpha_pixels; // mip levels + int servercount; uint hashValue; diff --git a/r_surf.c b/r_surf.c index 0a1db660..35503974 100644 --- a/r_surf.c +++ b/r_surf.c @@ -180,7 +180,6 @@ texture_t *R_TextureAnimation( msurface_t *s ) return base; } -static char r_transtexture; /* =============== R_DrawSurface @@ -200,7 +199,6 @@ void R_DrawSurface (void) surfrowbytes = r_drawsurf.rowbytes; mt = r_drawsurf.image; - r_transtexture = mt->transparent; r_source = mt->pixels[r_drawsurf.surfmip]; @@ -277,7 +275,6 @@ void R_DrawSurfaceBlock8_mip0 (void) psource = pbasesource; prowdest = prowdestbase; - char transtexture = r_transtexture; for (v=0 ; v=0; b--) { pix = psource[b]; - if( transtexture ) - pix = pix << 3; prowdest[b] = pix; //((unsigned char *)vid.colormap) //[(light & 0xFF00) + pix]; @@ -328,7 +323,6 @@ void R_DrawSurfaceBlock8_mip1 (void) { int v, i, b, lightstep, lighttemp, light; pixel_t pix, *psource, *prowdest; - char transtexture = r_transtexture; psource = pbasesource; prowdest = prowdestbase; @@ -353,8 +347,6 @@ void R_DrawSurfaceBlock8_mip1 (void) for (b=7; b>=0; b--) { pix = psource[b]; - if( transtexture ) - pix = pix << 3; prowdest[b] = pix; //((unsigned char *)vid.colormap) //[(light & 0xFF00) + pix]; @@ -382,7 +374,6 @@ void R_DrawSurfaceBlock8_mip2 (void) { int v, i, b, lightstep, lighttemp, light; pixel_t pix, *psource, *prowdest; - char transtexture = r_transtexture; psource = pbasesource; prowdest = prowdestbase; @@ -407,8 +398,6 @@ void R_DrawSurfaceBlock8_mip2 (void) for (b=3; b>=0; b--) { pix = psource[b]; - if( transtexture ) - pix = pix << 3; prowdest[b] = pix; //((unsigned char *)vid.colormap) //[(light & 0xFF00) + pix]; @@ -436,7 +425,6 @@ void R_DrawSurfaceBlock8_mip3 (void) { int v, i, b, lightstep, lighttemp, light; pixel_t pix, *psource, *prowdest; - char transtexture = r_transtexture; psource = pbasesource; prowdest = prowdestbase; @@ -461,8 +449,6 @@ void R_DrawSurfaceBlock8_mip3 (void) for (b=1; b>=0; b--) { pix = psource[b]; - if( transtexture ) - pix = pix << 3; prowdest[b] = pix; //((unsigned char *)vid.colormap) //[(light & 0xFF00) + pix];