From c08c35df698bcd142c99b49e639f4862bc394bab Mon Sep 17 00:00:00 2001 From: mittorn Date: Thu, 4 Apr 2019 04:44:06 +0700 Subject: [PATCH] ref_soft: FillRGBA, FillRGBABlend --- r_context.c | 8 ++++-- r_draw.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++--- r_local.h | 2 +- r_misc.c | 2 -- 4 files changed, 82 insertions(+), 8 deletions(-) diff --git a/r_context.c b/r_context.c index b9e32f1d..69855083 100644 --- a/r_context.c +++ b/r_context.c @@ -106,7 +106,9 @@ CL_FillRGBA */ static void CL_FillRGBA( float _x, float _y, float _w, float _h, int r, int g, int b, int a ) { - + vid.rendermode = kRenderTransAdd; + _TriColor4ub(r,g,b,a); + Draw_Fill(_x,_y,_w,_h); } /* @@ -117,7 +119,9 @@ pfnFillRGBABlend */ static void GAME_EXPORT CL_FillRGBABlend( float _x, float _y, float _w, float _h, int r, int g, int b, int a ) { - + vid.rendermode = kRenderTransAlpha; + _TriColor4ub(r,g,b,a); + Draw_Fill(_x,_y,_w,_h); } diff --git a/r_draw.c b/r_draw.c index 8cd3c79b..06117f3b 100644 --- a/r_draw.c +++ b/r_draw.c @@ -199,10 +199,82 @@ void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, f R_DrawStretchPicImplementation(x,y,w,h, pic->width * s1, pic->height * t1, pic->width * s2, pic->height * t2, pic); } -void Draw_Fill (int x, int y, int w, int h, int c) +void Draw_Fill (int x, int y, int w, int h) { - // todo: color - R_DrawStretchPicImplementation(x,y,w,h, 0, 0, 12, 1, tr.whiteTexture ); + pixel_t *dest; + unsigned int v, u; + unsigned int height; + int skip; + pixel_t src = vid.color; + int alpha = vid.alpha; + + if( x < 0 ) + x = 0; + + if( x + w > vid.width ) + w = vid.width - x; + + if( y + h > vid.height ) + h = vid.height - y; + + height = h; + if (y < 0) + { + skip = -y; + height += y; + y = 0; + } + else + skip = 0; + + dest = vid.buffer + y * vid.rowbytes + x; + + #pragma omp parallel for schedule(static) + for (v=0 ; v>16]; + f += fstep; + dest[u+1] = source[f>>16]; + f += fstep; + dest[u+2] = source[f>>16]; + f += fstep; + dest[u+3] = source[f>>16]; + f += fstep; + } +#else + for (u=0 ; u>8)] << 8 | (screen & 0xff) | ((src & 0xff) >> 0); + } + else if( alpha < 7) // && (vid.rendermode == kRenderTransAlpha || vid.rendermode == kRenderTransTexture ) ) + { + pixel_t screen = dest[u]; // | 0xff & screen & src ; + dest[u] = BLEND_ALPHA( alpha, src, screen);//vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) >> 3 | ((src & 0xff) >> 3); + + } + else + dest[u] = src; + + } +#endif + } + dest += vid.rowbytes; + } } /* diff --git a/r_local.h b/r_local.h index 7906dfc5..485a0a04 100644 --- a/r_local.h +++ b/r_local.h @@ -1252,7 +1252,7 @@ void D_FlushCaches( qboolean newmap ); // // r_draw.c // -void Draw_Fill (int x, int y, int w, int h, int c); +void Draw_Fill (int x, int y, int w, int h); // // r_misc.c diff --git a/r_misc.c b/r_misc.c index e4e3f3fe..7bbb66e2 100644 --- a/r_misc.c +++ b/r_misc.c @@ -111,8 +111,6 @@ void D_ViewChanged (void) if ( !RI.drawWorld ) { memset( d_pzbuffer, 0xff, vid.width * vid.height * sizeof( d_pzbuffer[0] ) ); - // newrefdef - Draw_Fill( 0, 0, gpGlobals->width, gpGlobals->height,( int ) sw_clearcolor->value & 0xff ); } D_Patch ();