Browse Source

ref_soft: FillRGBA, FillRGBABlend

pull/2/head
mittorn 6 years ago
parent
commit
c08c35df69
  1. 8
      r_context.c
  2. 78
      r_draw.c
  3. 2
      r_local.h
  4. 2
      r_misc.c

8
r_context.c

@ -106,7 +106,9 @@ CL_FillRGBA @@ -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 @@ -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);
}

78
r_draw.c

@ -199,10 +199,82 @@ void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, f @@ -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<height ; v++)
{
#ifdef _OPENMP
pixel_t *dest = vid.buffer + (y + v) * vid.rowbytes + x;
#endif
{
#if 0
for (u=0 ; u<w ; u+=4)
{
dest[u] = source[f>>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<w ; u++)
{
if( alpha == 0 )
continue;
if( vid.rendermode == kRenderTransAdd)
{
pixel_t screen = dest[u];
dest[u] = vid.addmap[src & 0xff00|(screen>>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;
}
}
/*

2
r_local.h

@ -1252,7 +1252,7 @@ void D_FlushCaches( qboolean newmap ); @@ -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

2
r_misc.c

@ -111,8 +111,6 @@ void D_ViewChanged (void) @@ -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 ();

Loading…
Cancel
Save