summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2011-03-25 19:59:39 +0300
committerAndrey Nazarov <skuller@skuller.net>2011-03-26 14:43:07 +0300
commitbc9ae76c1f5c91810cd36e5d19ccad3790b35715 (patch)
tree2c90fa2b993f10bc3924f53ea2fded0c8824d00c /src
parente7a0d43b36389b2a0304b30963b8db18517fd8e6 (diff)
Clean up and fix 32-bit color API.
Make color_t a union to work around aliasing issues. Get rid of FastColorCopy macro in favor of direct assignment. Get rid of DRAW_COLOR_* macros in favor of separate APIs for clearing and setting 32-bit color and alpha values. Rename R_DrawFill/R_DrawFillEx into R_DrawFill8/R_DrawFill32 for consistency. Remove unused fields from laser_t struct. Fix 32-bit particles fading out too soon. Fix console text drawing with software renderer. Fix possible SCR_ParseColor buffer overflow.
Diffstat (limited to 'src')
-rw-r--r--src/cl_console.c41
-rw-r--r--src/cl_fx.c9
-rw-r--r--src/cl_local.h4
-rw-r--r--src/cl_public.h23
-rw-r--r--src/cl_scrn.c133
-rw-r--r--src/cl_tent.c89
-rw-r--r--src/common.c3
-rw-r--r--src/common.h2
-rw-r--r--src/gl_draw.c86
-rw-r--r--src/gl_images.c4
-rw-r--r--src/gl_main.c11
-rw-r--r--src/gl_state.c4
-rw-r--r--src/gl_tess.c30
-rw-r--r--src/q_shared.h13
-rw-r--r--src/r_shared.h6
-rw-r--r--src/ref_public.h29
-rw-r--r--src/sw_draw.c41
-rw-r--r--src/sw_image.c9
-rw-r--r--src/sw_local.h2
-rw-r--r--src/sw_misc.c2
-rw-r--r--src/ui_atoms.c50
-rw-r--r--src/ui_demos.c4
-rw-r--r--src/ui_local.h8
-rw-r--r--src/ui_menu.c81
-rw-r--r--src/ui_multiplayer.c4
-rw-r--r--src/ui_playerconfig.c2
-rw-r--r--src/ui_script.c16
27 files changed, 332 insertions, 374 deletions
diff --git a/src/cl_console.c b/src/cl_console.c
index 0b10c35..c0c6fbf 100644
--- a/src/cl_console.c
+++ b/src/cl_console.c
@@ -618,14 +618,17 @@ static int Con_DrawLine( int v, int line, float alpha ) {
flags = UI_ALTCOLOR;
// fall through
case COLOR_NONE:
- VectorSet( color, 255, 255, 255 );
- color[3] = alpha * 255;
- R_SetColor( DRAW_COLOR_RGBA, color );
+ R_ClearColor();
+ if( alpha != 1 ) {
+ R_SetAlpha( alpha );
+ }
break;
default:
- VectorCopy( colorTable[c & 7], color );
- color[3] = alpha * 255;
- R_SetColor( DRAW_COLOR_RGBA, color );
+ color.u32 = colorTable[c & 7];
+ if( alpha != 1 ) {
+ color.u8[3] = alpha * 255;
+ }
+ R_SetColor( color.u32 );
break;
}
@@ -685,8 +688,8 @@ static void Con_DrawNotify( void ) {
v += CHAR_HEIGHT;
}
-
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+
+ R_ClearColor();
if( cls.key_dest & KEY_MESSAGE ) {
if( con.chat == CHAT_TEAM ) {
@@ -736,11 +739,7 @@ static void Con_DrawSolidConsole( void ) {
( cls.key_dest & KEY_MENU ) == 0 )
{
alpha = 0.5f + 0.5f * ( con.currentHeight / con_height->value );
-
- Cvar_ClampValue( con_alpha, 0, 1 );
- alpha *= con_alpha->value;
-
- R_SetColor( DRAW_COLOR_ALPHA, ( byte * )&alpha );
+ R_SetAlpha( alpha * Cvar_ClampValue( con_alpha, 0, 1 ) );
}
clip.left = 0;
@@ -766,7 +765,7 @@ static void Con_DrawSolidConsole( void ) {
// draw arrows to show the buffer is backscrolled
if( con.display != con.current ) {
- R_SetColor( DRAW_COLOR_RGBA, colorRed );
+ R_SetColor( U32_RED );
for( i = 1; i < con.linewidth / 2; i += 4 ) {
R_DrawChar( i * CHAR_WIDTH, y, 0, '^', con.charsetImage );
}
@@ -774,9 +773,9 @@ static void Con_DrawSolidConsole( void ) {
y -= CHAR_HEIGHT;
rows--;
}
-
+
// draw from the bottom up
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ R_ClearColor();
row = con.display;
widths[0] = widths[1] = 0;
for( i = 0; i < rows; i++ ) {
@@ -794,7 +793,7 @@ static void Con_DrawSolidConsole( void ) {
row--;
}
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ R_ClearColor();
//ZOID
// draw the download bar
@@ -858,9 +857,9 @@ static void Con_DrawSolidConsole( void ) {
i = 17;
break;
}
- R_SetColor( DRAW_COLOR_RGBA, colorYellow );
+ R_SetColor( U32_YELLOW );
R_DrawChar( CHAR_WIDTH, y, 0, i, con.charsetImage );
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ R_ClearColor();
// draw input line
x = IF_Draw( &con.prompt.inputLine, 2 * CHAR_WIDTH, y,
@@ -878,7 +877,7 @@ static void Con_DrawSolidConsole( void ) {
row++;
}
- R_SetColor( DRAW_COLOR_RGBA, colorCyan );
+ R_SetColor( U32_CYAN );
// draw clock
if( con_clock->integer ) {
@@ -896,7 +895,7 @@ static void Con_DrawSolidConsole( void ) {
}
// restore rendering parameters
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ R_ClearColor();
R_SetClipRect( DRAW_CLIP_DISABLED, NULL );
}
diff --git a/src/cl_fx.c b/src/cl_fx.c
index 26162e5..86a0a72 100644
--- a/src/cl_fx.c
+++ b/src/cl_fx.c
@@ -1875,9 +1875,14 @@ void CL_AddParticles (void)
part->origin[1] = p->org[1] + p->vel[1]*time + p->accel[1]*time2;
part->origin[2] = p->org[2] + p->vel[2]*time + p->accel[2]*time2;
- if( color == 255 ) {
- FastColorCopy( p->rgb, part->rgb );
+#if USE_REF == REF_GL
+ if( color == -1 ) {
+ part->rgba.u8[0] = p->rgba.u8[0];
+ part->rgba.u8[1] = p->rgba.u8[1];
+ part->rgba.u8[2] = p->rgba.u8[2];
+ part->rgba.u8[3] = p->rgba.u8[3] * alpha;
}
+#endif
part->color = color;
part->alpha = alpha;
diff --git a/src/cl_local.h b/src/cl_local.h
index e79a862..8aa5fc4 100644
--- a/src/cl_local.h
+++ b/src/cl_local.h
@@ -637,10 +637,10 @@ typedef struct cparticle_s {
vec3_t org;
vec3_t vel;
vec3_t accel;
- int color; // 255 -> use rgb
+ int color; // -1 => use rgba
float alpha;
float alphavel;
- color_t rgb;
+ color_t rgba;
} cparticle_t;
#if USE_DLIGHTS
diff --git a/src/cl_public.h b/src/cl_public.h
index 73aab52..71eed1c 100644
--- a/src/cl_public.h
+++ b/src/cl_public.h
@@ -79,17 +79,14 @@ void SCR_EndLoadingPlaque( void );
void SCR_ModeChanged( void );
void SCR_UpdateScreen( void );
-#define colorBlack colorTable[COLOR_BLACK]
-#define colorRed colorTable[COLOR_RED]
-#define colorGreen colorTable[COLOR_GREEN]
-#define colorYellow colorTable[COLOR_YELLOW]
-#define colorBlue colorTable[COLOR_BLUE]
-#define colorCyan colorTable[COLOR_CYAN]
-#define colorMagenta colorTable[COLOR_MAGENTA]
-#define colorWhite colorTable[COLOR_WHITE]
-
-#define MAKERGB(v,r,g,b) ((v)[0]=(r),(v)[1]=(g),(v)[2]=(b))
-#define MAKERGBA(v,r,g,b,a) ((v)[0]=(r),(v)[1]=(g),(v)[2]=(b),(v)[3]=(a))
+#define U32_BLACK MakeColor( 0, 0, 0, 255 )
+#define U32_RED MakeColor( 255, 0, 0, 255 )
+#define U32_GREEN MakeColor( 0, 255, 0, 255 )
+#define U32_YELLOW MakeColor( 255, 255, 0, 255 )
+#define U32_BLUE MakeColor( 0, 0, 255, 255 )
+#define U32_CYAN MakeColor( 0, 255, 255, 255 )
+#define U32_MAGENTA MakeColor( 255, 0, 255, 255 )
+#define U32_WHITE MakeColor( 255, 255, 255, 255 )
#define CHAR_WIDTH 8
#define CHAR_HEIGHT 8
@@ -108,9 +105,9 @@ void SCR_UpdateScreen( void );
#define UI_MULTILINE 0x00000200
#define UI_DRAWCURSOR 0x00000400
-extern const color_t colorTable[8];
+extern const uint32_t colorTable[8];
-qboolean SCR_ParseColor( const char *s, color_t color );
+qboolean SCR_ParseColor( const char *s, color_t *color );
float V_CalcFov( float fov_x, float width, float height );
diff --git a/src/cl_scrn.c b/src/cl_scrn.c
index 9e1f655..d18ad16 100644
--- a/src/cl_scrn.c
+++ b/src/cl_scrn.c
@@ -101,15 +101,9 @@ static const char *const sb_nums[2][STAT_PICS] = {
"anum_6", "anum_7", "anum_8", "anum_9", "anum_minus" }
};
-const color_t colorTable[8] = {
- { 0, 0, 0, 255 },
- { 255, 0, 0, 255 },
- { 0, 255, 0, 255 },
- { 255, 255, 0, 255 },
- { 0, 0, 255, 255 },
- { 0, 255, 255, 255 },
- { 255, 0, 255, 255 },
- { 255, 255, 255, 255 }
+const uint32_t colorTable[8] = {
+ U32_BLACK, U32_RED, U32_GREEN, U32_YELLOW,
+ U32_BLUE, U32_CYAN, U32_MAGENTA, U32_WHITE
};
/*
@@ -203,50 +197,57 @@ float SCR_FadeAlpha( unsigned startTime, unsigned visTime, unsigned fadeTime ) {
return alpha;
}
-qboolean SCR_ParseColor( const char *s, color_t color ) {
+qboolean SCR_ParseColor( const char *s, color_t *color ) {
int i;
int c[8];
+ // parse generic color
if( *s == '#' ) {
s++;
for( i = 0; s[i]; i++ ) {
+ if( i == 8 ) {
+ return qfalse;
+ }
c[i] = Q_charhex( s[i] );
if( c[i] == -1 ) {
return qfalse;
}
}
+
switch( i ) {
case 3:
- color[0] = c[0] | ( c[0] << 4 );
- color[1] = c[1] | ( c[1] << 4 );
- color[2] = c[2] | ( c[2] << 4 );
- color[3] = 255;
+ color->u8[0] = c[0] | ( c[0] << 4 );
+ color->u8[1] = c[1] | ( c[1] << 4 );
+ color->u8[2] = c[2] | ( c[2] << 4 );
+ color->u8[3] = 255;
break;
case 6:
- color[0] = c[1] | ( c[0] << 4 );
- color[1] = c[3] | ( c[2] << 4 );
- color[2] = c[5] | ( c[4] << 4 );
- color[3] = 255;
+ color->u8[0] = c[1] | ( c[0] << 4 );
+ color->u8[1] = c[3] | ( c[2] << 4 );
+ color->u8[2] = c[5] | ( c[4] << 4 );
+ color->u8[3] = 255;
break;
case 8:
- color[0] = c[1] | ( c[0] << 4 );
- color[1] = c[3] | ( c[2] << 4 );
- color[2] = c[5] | ( c[4] << 4 );
- color[3] = c[7] | ( c[6] << 4 );
+ color->u8[0] = c[1] | ( c[0] << 4 );
+ color->u8[1] = c[3] | ( c[2] << 4 );
+ color->u8[2] = c[5] | ( c[4] << 4 );
+ color->u8[3] = c[7] | ( c[6] << 4 );
break;
default:
return qfalse;
}
- return qtrue;
- } else {
- i = Com_ParseColor( s, COLOR_WHITE );
- if( i == COLOR_NONE ) {
- return qfalse;
- }
- FastColorCopy( colorTable[i], color );
return qtrue;
}
+
+ // parse name or index
+ i = Com_ParseColor( s, COLOR_WHITE );
+ if( i == COLOR_NONE ) {
+ return qfalse;
+ }
+
+ color->u32 = colorTable[i];
+ return qtrue;
}
/*
@@ -334,7 +335,7 @@ static void SCR_DrawDebugGraph (void)
x = w-1;
y = r_config.height;
- R_DrawFill (x, y-scr_graphheight->value,
+ R_DrawFill8 (x, y-scr_graphheight->value,
w, scr_graphheight->value, 8);
for (a=0 ; a<w ; a++)
@@ -347,7 +348,7 @@ static void SCR_DrawDebugGraph (void)
if (v < 0)
v += scr_graphheight->value * (1+(int)(-v/scr_graphheight->value));
h = (int)v % (int)scr_graphheight->value;
- R_DrawFill (x, y - h, 1, h, color);
+ R_DrawFill8 (x, y - h, 1, h, color);
x--;
}
}
@@ -362,8 +363,8 @@ static void draw_percent_bar( int percent ) {
w = scr.hud_width * percent / 100;
- R_DrawFill( 0, scr.hud_height, w, CHAR_HEIGHT, 4 );
- R_DrawFill( w, scr.hud_height, scr.hud_width - w, CHAR_HEIGHT, 0 );
+ R_DrawFill8( 0, scr.hud_height, w, CHAR_HEIGHT, 4 );
+ R_DrawFill8( w, scr.hud_height, scr.hud_width - w, CHAR_HEIGHT, 0 );
len = Q_scnprintf( buffer, sizeof( buffer ), "%d%%", percent );
x = ( scr.hud_width - len * CHAR_WIDTH ) / 2;
@@ -458,14 +459,14 @@ static void draw_center_string( void ) {
return;
}
- R_SetColor( DRAW_COLOR_ALPHA, ( byte * )&alpha );
+ R_SetAlpha( alpha );
y = scr.hud_height / 4 - scr_center_lines * 8 / 2;
SCR_DrawStringMulti( scr.hud_width / 2, y, UI_CENTER,
MAX_STRING_CHARS, scr_centerstring, scr.font_pic );
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ R_ClearColor();
}
/*
@@ -543,7 +544,7 @@ static void draw_ping_graph( int x, int y ) {
v = LAG_HEIGHT;
}
- R_DrawFill( x + LAG_WIDTH - i - 1, y + LAG_HEIGHT - v, 1, v, c );
+ R_DrawFill8( x + LAG_WIDTH - i - 1, y + LAG_HEIGHT - v, 1, v, c );
}
}
@@ -561,7 +562,7 @@ static void draw_lagometer( void ) {
// draw ping graph
if( scr_lag_draw->integer ) {
if( scr_lag_draw->integer > 1 ) {
- R_DrawFill( x, y, LAG_WIDTH, LAG_HEIGHT, 4 );
+ R_DrawFill8( x, y, LAG_WIDTH, LAG_HEIGHT, 4 );
}
draw_ping_graph( x, y );
}
@@ -624,9 +625,8 @@ static void SCR_Draw_f( void ) {
const char *s, *c;
drawobj_t *obj;
cmd_macro_t *macro;
- // int stat;
- color_t color = { 0, 0, 0, 0 };
- int flags = UI_IGNORECOLOR;
+ color_t color;
+ int flags;
int argc = Cmd_Argc();
if( argc == 1 ) {
@@ -648,6 +648,9 @@ static void SCR_Draw_f( void ) {
return;
}
+ color.u32 = U32_BLACK;
+ flags = UI_IGNORECOLOR;
+
s = Cmd_Argv( 1 );
x = atoi( Cmd_Argv( 2 ) );
if( x < 0 ) {
@@ -660,7 +663,7 @@ static void SCR_Draw_f( void ) {
if( !strcmp( c, "alt" ) ) {
flags |= UI_ALTCOLOR;
} else {
- if( !SCR_ParseColor( c, color ) ) {
+ if( !SCR_ParseColor( c, &color ) ) {
Com_Printf( "Unknown color '%s'\n", c );
return;
}
@@ -672,7 +675,7 @@ static void SCR_Draw_f( void ) {
obj->x = x;
obj->y = y;
obj->flags = flags;
- FastColorCopy( color, obj->color );
+ obj->color.u32 = color.u32;
macro = Cmd_FindMacro( s );
if( macro ) {
@@ -772,7 +775,7 @@ static void draw_objects( void ) {
y += scr.hud_height - CHAR_HEIGHT + 1;
}
if( !( obj->flags & UI_IGNORECOLOR ) ) {
- R_SetColor( DRAW_COLOR_RGBA, obj->color );
+ R_SetColor( obj->color.u32 );
}
if( obj->macro ) {
obj->macro->function( buffer, sizeof( buffer ) );
@@ -780,7 +783,7 @@ static void draw_objects( void ) {
} else {
SCR_DrawString( x, y, obj->flags, obj->cvar->string );
}
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ R_ClearColor();
}
}
@@ -834,10 +837,10 @@ static void draw_stats( void ) {
for( i = 0; i < j; i++ ) {
Q_snprintf( buffer, sizeof( buffer ), "%2d: %d", i, cl.frame.ps.stats[i] );
if( cl.oldframe.ps.stats[i] != cl.frame.ps.stats[i] ) {
- R_SetColor( DRAW_COLOR_RGBA, colorRed );
+ R_SetColor( U32_RED );
}
R_DrawString( x, y, 0, MAX_STRING_CHARS, buffer, scr.font_pic );
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ R_ClearColor();
y += CHAR_HEIGHT;
}
}
@@ -1008,11 +1011,11 @@ static void scr_crosshair_changed( cvar_t *self ) {
if( ch_health->integer ) {
SCR_SetCrosshairColor();
} else {
- scr.crosshair_color[0] = (byte)(ch_red->value * 255);
- scr.crosshair_color[1] = (byte)(ch_green->value * 255);
- scr.crosshair_color[2] = (byte)(ch_blue->value * 255);
+ scr.crosshair_color.u8[0] = (byte)(ch_red->value * 255);
+ scr.crosshair_color.u8[1] = (byte)(ch_green->value * 255);
+ scr.crosshair_color.u8[2] = (byte)(ch_blue->value * 255);
}
- scr.crosshair_color[3] = (byte)(ch_alpha->value * 255);
+ scr.crosshair_color.u8[3] = (byte)(ch_alpha->value * 255);
} else {
scr.crosshair_pic = 0;
}
@@ -1027,29 +1030,29 @@ void SCR_SetCrosshairColor( void ) {
health = cl.frame.ps.stats[STAT_HEALTH];
if( health <= 0 ) {
- VectorSet( scr.crosshair_color, 0, 0, 0 );
+ VectorSet( scr.crosshair_color.u8, 0, 0, 0 );
return;
}
// red
- scr.crosshair_color[0] = 255;
+ scr.crosshair_color.u8[0] = 255;
// green
if( health >= 66 ) {
- scr.crosshair_color[1] = 255;
+ scr.crosshair_color.u8[1] = 255;
} else if( health < 33 ) {
- scr.crosshair_color[1] = 0;
+ scr.crosshair_color.u8[1] = 0;
} else {
- scr.crosshair_color[1] = ( 255 * ( health - 33 ) ) / 33;
+ scr.crosshair_color.u8[1] = ( 255 * ( health - 33 ) ) / 33;
}
// blue
if( health >= 99 ) {
- scr.crosshair_color[2] = 255;
+ scr.crosshair_color.u8[2] = 255;
} else if( health < 66 ) {
- scr.crosshair_color[2] = 0;
+ scr.crosshair_color.u8[2] = 0;
} else {
- scr.crosshair_color[2] = ( 255 * ( health - 66 ) ) / 33;
+ scr.crosshair_color.u8[2] = ( 255 * ( health - 66 ) ) / 33;
}
}
@@ -1682,10 +1685,10 @@ static void draw_crosshair( void ) {
x += ch_x->integer;
y += ch_y->integer;
- R_SetColor( DRAW_COLOR_RGBA, scr.crosshair_color );
+ R_SetColor( scr.crosshair_color.u32 );
R_DrawStretchPic( x, y, scr.crosshair_width, scr.crosshair_height,
scr.crosshair_pic );
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ R_ClearColor();
}
static void draw_2d( void ) {
@@ -1711,14 +1714,13 @@ static void draw_2d( void ) {
}
#endif
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ R_ClearColor();
if( scr_crosshair->integer ) {
draw_crosshair();
}
- Cvar_ClampValue( scr_alpha, 0, 1 );
- R_SetColor( DRAW_COLOR_ALPHA, ( byte * )&scr_alpha->value );
+ R_SetAlpha( Cvar_ClampValue( scr_alpha, 0, 1 ) );
if( scr_draw2d->integer > 1 ) {
draw_layout_string( cl.configstrings[CS_STATUSBAR] );
@@ -1740,7 +1742,7 @@ static void draw_2d( void ) {
draw_lagometer();
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ R_ClearColor();
if( cl.frameflags && scr_showturtle->integer > 0 ) {
draw_turtle();
@@ -1769,8 +1771,7 @@ static void draw_2d( void ) {
static void draw_active_frame( void ) {
if( cls.state < ca_active ) {
// draw black background if not active
- R_DrawFill( 0, 0, r_config.width,
- r_config.height, 0 );
+ R_DrawFill8( 0, 0, r_config.width, r_config.height, 0 );
return;
}
diff --git a/src/cl_tent.c b/src/cl_tent.c
index 47270ac..d99a1e9 100644
--- a/src/cl_tent.c
+++ b/src/cl_tent.c
@@ -353,20 +353,15 @@ LASER MANAGEMENT
==============================================================
*/
-#define LASER_FADE_NOT 1
-#define LASER_FADE_ALPHA 2
-#define LASER_FADE_RGBA 3
-
typedef struct {
- entity_t ent;
vec3_t start;
vec3_t end;
- int fadeType;
- qboolean indexed;
- color_t color;
- float width;
- int lifeTime;
- int startTime;
+ int color;
+#if USE_REF == REF_GL
+ color_t rgba;
+#endif
+ int width;
+ int lifetime, starttime;
} laser_t;
#define MAX_LASERS 32
@@ -381,10 +376,10 @@ static laser_t *alloc_laser( void ) {
laser_t *l;
int i;
- for( i=0, l=cl_lasers ; i<MAX_LASERS ; i++, l++ ) {
- if( cl.time - l->startTime >= l->lifeTime ) {
+ for( i = 0, l = cl_lasers; i < MAX_LASERS; i++, l++ ) {
+ if( cl.time - l->starttime >= l->lifetime ) {
memset( l, 0, sizeof( *l ) );
- l->startTime = cl.time;
+ l->starttime = cl.time;
return l;
}
}
@@ -396,40 +391,32 @@ static void CL_AddLasers( void ) {
laser_t *l;
entity_t ent;
int i;
- //color_t color;
- int time;
- float f;
+ int time;
memset( &ent, 0, sizeof( ent ) );
for( i = 0, l = cl_lasers; i < MAX_LASERS; i++, l++ ) {
- time = l->lifeTime - ( cl.time - l->startTime );
+ time = l->lifetime - ( cl.time - l->starttime );
if( time < 0 ) {
continue;
}
- ent.alpha = l->color[3] / 255.0f;
-
- if( l->fadeType != LASER_FADE_NOT ) {
- f = (float)time / (float)l->lifeTime;
-
- ent.alpha *= f;
- /*if( l->fadeType == LASER_FADE_RGBA ) {
- *(int *)color = *(int *)l->color;
- color[0] *= f;
- color[1] *= f;
- color[2] *= f;
- ent.skinnum = *(int *)color;
- }*/
- } /*else*/ {
- ent.skinnum = *(uint32_t *)l->color;
+#if USE_REF == REF_GL
+ if( l->color == -1 ) {
+ float f = (float)time / (float)l->lifetime;
+ ent.rgba.u8[0] = l->rgba.u8[0];
+ ent.rgba.u8[1] = l->rgba.u8[1];
+ ent.rgba.u8[2] = l->rgba.u8[2];
+ ent.rgba.u8[3] = l->rgba.u8[3] * f;
}
+#endif
+ ent.alpha = 0.30f;
+ ent.skinnum = l->color;
ent.flags = RF_TRANSLUCENT|RF_BEAM;
VectorCopy( l->start, ent.origin );
VectorCopy( l->end, ent.oldorigin );
ent.frame = l->width;
- ent.lightstyle = !l->indexed;
V_AddEntity( &ent );
}
@@ -449,13 +436,8 @@ static void CL_ParseLaser( int colors ) {
VectorCopy( te.pos1, l->start );
VectorCopy( te.pos2, l->end );
- l->fadeType = LASER_FADE_NOT;
- l->lifeTime = 100;
- l->indexed = qtrue;
- l->color[0] = ( colors >> ( ( rand() % 4 ) * 8 ) ) & 0xff;
- l->color[1] = 0;
- l->color[2] = 0;
- l->color[3] = 77;
+ l->lifetime = 100;
+ l->color = ( colors >> ( ( rand() % 4 ) * 8 ) ) & 0xff;
l->width = 4;
}
@@ -1028,16 +1010,18 @@ static cvar_t *cl_railspiral_color;
static cvar_t *cl_railspiral_radius;
static void cl_railcore_color_changed( cvar_t *self ) {
- if( !SCR_ParseColor( self->string, railcore_color ) ) {
+ if( !SCR_ParseColor( self->string, &railcore_color ) ) {
Com_WPrintf( "Invalid value '%s' for '%s'\n", self->string, self->name );
- FastColorCopy( colorRed, railcore_color );
+ Cvar_Reset( self );
+ railcore_color.u32 = U32_RED;
}
}
static void cl_railspiral_color_changed( cvar_t *self ) {
- if( !SCR_ParseColor( self->string, railspiral_color ) ) {
+ if( !SCR_ParseColor( self->string, &railspiral_color ) ) {
Com_WPrintf( "Invalid value '%s' for '%s'\n", self->string, self->name );
- FastColorCopy( colorBlue, railspiral_color );
+ Cvar_Reset( self );
+ railspiral_color.u32 = U32_BLUE;
}
}
@@ -1050,11 +1034,10 @@ static void CL_RailCore( void ) {
VectorCopy( te.pos1, l->start );
VectorCopy( te.pos2, l->end );
- l->fadeType = LASER_FADE_RGBA;
- l->lifeTime = 1000 * cl_railtrail_time->value;
- l->indexed = qfalse;
- l->width = cl_railcore_width->value;
- FastColorCopy( railcore_color, l->color );
+ l->color = -1;
+ l->lifetime = 1000 * cl_railtrail_time->value;
+ l->width = cl_railcore_width->integer;
+ l->rgba.u32 = railcore_color.u32;
}
static void CL_RailSpiral( void ) {
@@ -1090,10 +1073,10 @@ static void CL_RailSpiral( void ) {
VectorScale( right, c, dir );
VectorMA( dir, s, up, dir );
- p->alpha = railspiral_color[3] / 255.0f;
+ p->alpha = 1.0;
p->alphavel = -1.0 / ( cl_railtrail_time->value + frand() * 0.2 );
- p->color = 0xff;
- FastColorCopy( railspiral_color, p->rgb );
+ p->color = -1;
+ p->rgba.u32 = railspiral_color.u32;
for( j=0 ; j<3 ; j++ ) {
p->org[j] = move[j] + dir[j] * cl_railspiral_radius->value;
p->vel[j] = dir[j] * 6;
diff --git a/src/common.c b/src/common.c
index 2f33469..eecf8d5 100644
--- a/src/common.c
+++ b/src/common.c
@@ -1360,7 +1360,7 @@ qboolean Com_WildCmpEx( const char *filter, const char *string, int term, qboole
==============================================================================
*/
-const char colorNames[10][8] = {
+const char *const colorNames[10] = {
"black", "red", "green", "yellow",
"blue", "cyan", "magenta", "white",
"alt", "none"
@@ -1387,6 +1387,7 @@ color_index_t Com_ParseColor( const char *s, color_index_t last ) {
return i;
}
}
+
return COLOR_NONE;
}
diff --git a/src/common.h b/src/common.h
index 980d85f..5b21cf3 100644
--- a/src/common.h
+++ b/src/common.h
@@ -625,7 +625,7 @@ extern time_t com_startTime;
extern qhandle_t com_logFile;
-extern const char colorNames[10][8];
+extern const char *const colorNames[10];
void Qcommon_Init( int argc, char **argv );
void Qcommon_Frame( void );
diff --git a/src/gl_draw.c b/src/gl_draw.c
index d6ec85a..5b61794 100644
--- a/src/gl_draw.c
+++ b/src/gl_draw.c
@@ -25,7 +25,7 @@ drawStatic_t draw;
static inline void _GL_StretchPic(
float x, float y, float w, float h,
float s1, float t1, float s2, float t2,
- const byte *color, int texnum, int flags )
+ uint32_t color, int texnum, int flags )
{
vec_t *dst_vert;
uint32_t *dst_color;
@@ -47,10 +47,10 @@ static inline void _GL_StretchPic(
Vector4Set( dst_vert + 12, x, y + h, s1, t2 );
dst_color = ( uint32_t * )tess.colors + tess.numverts;
- dst_color[0] = *( const uint32_t * )color;
- dst_color[1] = *( const uint32_t * )color;
- dst_color[2] = *( const uint32_t * )color;
- dst_color[3] = *( const uint32_t * )color;
+ dst_color[0] = color;
+ dst_color[1] = color;
+ dst_color[2] = color;
+ dst_color[3] = color;
dst_indices = tess.indices + tess.numindices;
dst_indices[0] = tess.numverts + 0;
@@ -68,7 +68,9 @@ static inline void _GL_StretchPic(
}
}
- if( color[3] != 255 ) {
+#define U32_ALPHA MakeColor( 0, 0, 0, 255 )
+
+ if( ( color & U32_ALPHA ) != U32_ALPHA ) {
tess.flags |= 2;
}
@@ -80,42 +82,30 @@ static inline void _GL_StretchPic(
_GL_StretchPic(x,y,w,h,s1,t1,s2,t2,color,(image)->texnum,(image)->flags)
void GL_Blend( void ) {
- color_t color = {
- glr.fd.blend[0] * 255,
- glr.fd.blend[1] * 255,
- glr.fd.blend[2] * 255,
- glr.fd.blend[3] * 255
- };
+ color_t color;
+
+ color.u8[0] = glr.fd.blend[0] * 255;
+ color.u8[1] = glr.fd.blend[1] * 255;
+ color.u8[2] = glr.fd.blend[2] * 255;
+ color.u8[3] = glr.fd.blend[3] * 255;
_GL_StretchPic( glr.fd.x, glr.fd.y, glr.fd.width, glr.fd.height, 0, 0, 1, 1,
- color, TEXNUM_WHITE, 0 );
+ color.u32, TEXNUM_WHITE, 0 );
}
-void R_SetColor( int flags, const color_t color ) {
- draw.flags &= ~DRAW_COLOR_MASK;
+void R_ClearColor( void ) {
+ draw.colors[0].u32 = U32_WHITE;
+ draw.colors[1].u32 = U32_WHITE;
+}
- if( flags == DRAW_COLOR_CLEAR ) {
- FastColorCopy( colorWhite, draw.colors[0] );
- FastColorCopy( colorWhite, draw.colors[1] );
- return;
- }
- if( flags == DRAW_COLOR_ALPHA ) {
- draw.colors[0][3] = *( float * )color * 255;
- draw.colors[1][3] = *( float * )color * 255;
- } else if( flags == DRAW_COLOR_INDEXED ) {
- *( uint32_t * )draw.colors[0] = d_8to24table[ *( uint32_t * )color & 255 ];
- } else {
- if( flags & DRAW_COLOR_RGB ) {
- VectorCopy( color, draw.colors[0] );
- VectorCopy( colorWhite, draw.colors[1] );
- }
- if( flags & DRAW_COLOR_ALPHA ) {
- draw.colors[0][3] = color[3];
- draw.colors[1][3] = color[3];
- }
- }
+void R_SetAlpha( float alpha ) {
+ draw.colors[0].u8[3] =
+ draw.colors[1].u8[3] = alpha * 255;
+}
- draw.flags |= flags;
+void R_SetColor( uint32_t color ) {
+ draw.colors[0].u32 = color;
+ draw.colors[1].u8[3] = draw.colors[0].u8[3];
}
void R_SetClipRect( int flags, const clipRect_t *clip ) {
@@ -213,36 +203,36 @@ void R_DrawStretchPicST( int x, int y, int w, int h, float s1, float t1,
float s2, float t2, qhandle_t pic )
{
/* TODO: scrap support */
- GL_StretchPic( x, y, w, h, s1, t1, s2, t2, draw.colors[0], IMG_ForHandle( pic ) );
+ GL_StretchPic( x, y, w, h, s1, t1, s2, t2,
+ draw.colors[0].u32, IMG_ForHandle( pic ) );
}
void R_DrawStretchPic( int x, int y, int w, int h, qhandle_t pic ) {
image_t *image = IMG_ForHandle( pic );
GL_StretchPic( x, y, w, h, image->sl, image->tl, image->sh, image->th,
- draw.colors[0], image );
+ draw.colors[0].u32, image );
}
void R_DrawPic( int x, int y, qhandle_t pic ) {
image_t *image = IMG_ForHandle( pic );
GL_StretchPic( x, y, image->width, image->height,
- image->sl, image->tl, image->sh, image->th, draw.colors[0], image );
+ image->sl, image->tl, image->sh, image->th, draw.colors[0].u32, image );
}
#define DIV64 ( 1.0f / 64.0f )
void R_TileClear( int x, int y, int w, int h, qhandle_t pic ) {
GL_StretchPic( x, y, w, h, x * DIV64, y * DIV64,
- ( x + w ) * DIV64, ( y + h ) * DIV64, colorWhite, IMG_ForHandle( pic ) );
+ ( x + w ) * DIV64, ( y + h ) * DIV64, U32_WHITE, IMG_ForHandle( pic ) );
}
-void R_DrawFill( int x, int y, int w, int h, int c ) {
- _GL_StretchPic( x, y, w, h, 0, 0, 1, 1, ( byte * )&d_8to24table[c & 255],
- TEXNUM_WHITE, 0 );
+void R_DrawFill8( int x, int y, int w, int h, int c ) {
+ _GL_StretchPic( x, y, w, h, 0, 0, 1, 1, d_8to24table[c & 0xff], TEXNUM_WHITE, 0 );
}
-void R_DrawFillEx( int x, int y, int w, int h, const color_t color ) {
+void R_DrawFill32( int x, int y, int w, int h, uint32_t color ) {
_GL_StretchPic( x, y, w, h, 0, 0, 1, 1, color, TEXNUM_WHITE, 0 );
}
@@ -257,7 +247,7 @@ static inline void draw_char( int x, int y, int c, qboolean alt, image_t *image
s = ( c & 15 ) * 0.0625f;
t = ( c >> 4 ) * 0.0625f;
GL_StretchPic( x, y, CHAR_WIDTH, CHAR_HEIGHT, s, t,
- s + 0.0625f, t + 0.0625f, draw.colors[alt], image );
+ s + 0.0625f, t + 0.0625f, draw.colors[alt].u32, image );
}
void R_DrawChar( int x, int y, int flags, int c, qhandle_t font ) {
@@ -301,7 +291,7 @@ void Draw_Stringf( int x, int y, const char *fmt, ... ) {
t = ( c >> 4 ) * 0.0625f;
GL_StretchPic( x, y, CHAR_WIDTH, CHAR_HEIGHT, s, t,
- s + 0.0625f, t + 0.0625f, colorWhite, r_charset );
+ s + 0.0625f, t + 0.0625f, U32_WHITE, r_charset );
x += CHAR_WIDTH;
}
}
@@ -355,13 +345,13 @@ void Draw_Lightmaps( void ) {
x = i & 1;
y = i >> 1;
_GL_StretchPic( 256*x, 256*y, 256, 256,
- 0, 0, 1, 1, colorWhite, TEXNUM_LIGHTMAP+i, 0 );
+ 0, 0, 1, 1, U32_WHITE, TEXNUM_LIGHTMAP+i, 0 );
}
}
void Draw_Scrap( void ) {
_GL_StretchPic( 0, 0, 256, 256,
- 0, 0, 1, 1, colorWhite, TEXNUM_SCRAP, if_paletted|if_transparent );
+ 0, 0, 1, 1, U32_WHITE, TEXNUM_SCRAP, if_paletted|if_transparent );
}
#endif
diff --git a/src/gl_images.c b/src/gl_images.c
index aecb364..ffcbba5 100644
--- a/src/gl_images.c
+++ b/src/gl_images.c
@@ -982,13 +982,13 @@ static void GL_InitParticleTexture( void ) {
static void GL_InitWhiteImage( void ) {
uint32_t pixel;
- pixel = MakeColor( 0xff, 0xff, 0xff, 0xff );
+ pixel = U32_WHITE;
GL_BindTexture( TEXNUM_WHITE );
GL_Upload32( ( byte * )&pixel, 1, 1, qfalse );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
- pixel = MakeColor( 0, 0, 0, 0xff );
+ pixel = U32_BLACK;
GL_BindTexture( TEXNUM_BLACK );
GL_Upload32( ( byte * )&pixel, 1, 1, qfalse );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
diff --git a/src/gl_main.c b/src/gl_main.c
index ec3d9a6..6993fbd 100644
--- a/src/gl_main.c
+++ b/src/gl_main.c
@@ -338,13 +338,10 @@ static void GL_DrawSpriteModel( model_t *model ) {
}
static void GL_DrawNullModel( void ) {
- static const color_t colors[6] = {
- { 255, 0, 0, 255 },
- { 255, 0, 0, 255 },
- { 0, 255, 0, 255 },
- { 0, 255, 0, 255 },
- { 0, 0, 255, 255 },
- { 0, 0, 255, 255 }
+ static const uint32_t colors[6] = {
+ U32_RED, U32_RED,
+ U32_GREEN, U32_GREEN,
+ U32_BLUE, U32_BLUE
};
entity_t *e = glr.ent;
vec3_t points[6];
diff --git a/src/gl_state.c b/src/gl_state.c
index 41d8289..353fc98 100644
--- a/src/gl_state.c
+++ b/src/gl_state.c
@@ -157,8 +157,8 @@ void GL_Setup2D( void ) {
qglOrtho( 0, r_config.width, r_config.height, 0, -1, 1 );
draw.scale = 1;
- FastColorCopy( colorWhite, draw.colors[0] );
- FastColorCopy( colorWhite, draw.colors[1] );
+ draw.colors[0].u32 = U32_WHITE;
+ draw.colors[1].u32 = U32_WHITE;
if( draw.flags & DRAW_CLIP_MASK ) {
qglDisable( GL_SCISSOR_TEST );
diff --git a/src/gl_tess.c b/src/gl_tess.c
index 2cb9e65..967a57e 100644
--- a/src/gl_tess.c
+++ b/src/gl_tess.c
@@ -119,12 +119,12 @@ void GL_DrawParticles( void ) {
scale += dist * 0.01f;
}
- if( p->color == 255 ) {
- FastColorCopy( p->rgb, color );
+ if( p->color == -1 ) {
+ color.u32 = p->rgba.u32;
} else {
- *( uint32_t * )color = d_8to24table[p->color & 255];
+ color.u32 = d_8to24table[p->color & 0xff];
+ color.u8[3] = 255 * p->alpha;
}
- color[3] = p->alpha * 255;
if( numverts + 3 > TESS_MAX_VERTICES ) {
qglDrawArrays( GL_TRIANGLES, 0, numverts );
@@ -149,9 +149,9 @@ void GL_DrawParticles( void ) {
dst_vert[13] = PARTICLE_SIZE; dst_vert[14] = 0;
dst_color = ( uint32_t * )tess.colors + numverts;
- dst_color[0] = *( uint32_t * )color;
- dst_color[1] = *( uint32_t * )color;
- dst_color[2] = *( uint32_t * )color;
+ dst_color[0] = color.u32;
+ dst_color[1] = color.u32;
+ dst_color[2] = color.u32;
numverts += 3;
}
@@ -210,12 +210,12 @@ void GL_DrawBeams( void ) {
length = VectorLength( d1 );
- if( ent->lightstyle ) {
- *( uint32_t * )color = *( uint32_t * )&ent->skinnum;
+ if( ent->skinnum == -1 ) {
+ color.u32 = ent->rgba.u32;
} else {
- *( uint32_t * )color = d_8to24table[ent->skinnum & 0xFF];
+ color.u32 = d_8to24table[ent->skinnum & 0xff];
+ color.u8[3] = 255 * ent->alpha;
}
- color[3] = 255 * ent->alpha;
if( numverts + 4 > TESS_MAX_VERTICES ||
numindices + 6 > TESS_MAX_INDICES )
@@ -237,10 +237,10 @@ void GL_DrawBeams( void ) {
dst_vert[18] = 0; dst_vert[19] = length;
dst_color = ( uint32_t * )tess.colors + numverts;
- dst_color[0] = *( uint32_t * )color;
- dst_color[1] = *( uint32_t * )color;
- dst_color[2] = *( uint32_t * )color;
- dst_color[3] = *( uint32_t * )color;
+ dst_color[0] = color.u32;
+ dst_color[1] = color.u32;
+ dst_color[2] = color.u32;
+ dst_color[3] = color.u32;
dst_indices = tess.indices + numindices;
dst_indices[0] = numverts + 0;
diff --git a/src/q_shared.h b/src/q_shared.h
index 9817c23..0c3d19b 100644
--- a/src/q_shared.h
+++ b/src/q_shared.h
@@ -174,7 +174,10 @@ typedef vec_t vec5_t[5];
typedef float mat4_t[16];
-typedef unsigned char color_t[4];
+typedef union {
+ uint32_t u32;
+ uint8_t u8[4];
+} color_t;
typedef int fixed4_t;
typedef int fixed8_t;
@@ -284,8 +287,6 @@ static inline float Q_fabs( float f ) {
#define Vector4Negate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2],(b)[3]=-(a)[3])
#define Vector4Set(v, a, b, c, d) ((v)[0]=(a),(v)[1]=(b),(v)[2]=(c),(v)[3]=(d))
-#define FastColorCopy(a,b) memcpy(b,a,4)
-
void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
vec_t VectorNormalize (vec3_t v); // returns vector length
vec_t VectorNormalize2 (vec3_t v, vec3_t out);
@@ -552,6 +553,12 @@ static inline float FloatSwap( float f ) {
(b)[1]=LittleFloat((a)[1]),\
(b)[2]=LittleFloat((a)[2]))
+#if USE_BGRA
+#define MakeColor( r, g, b, a ) MakeRawLong( b, g, r, a )
+#else
+#define MakeColor( r, g, b, a ) MakeRawLong( r, g, b, a )
+#endif
+
//=============================================
//
diff --git a/src/r_shared.h b/src/r_shared.h
index 4e4cdc7..e0f5b87 100644
--- a/src/r_shared.h
+++ b/src/r_shared.h
@@ -26,12 +26,6 @@ IMAGE MANAGER
=============================================================================
*/
-#if USE_BGRA
-#define MakeColor( r, g, b, a ) MakeRawLong( b, g, r, a )
-#else
-#define MakeColor( r, g, b, a ) MakeRawLong( r, g, b, a )
-#endif
-
#define R_Malloc( size ) Z_TagMalloc( size, TAG_RENDERER )
#define R_Mallocz( size ) Z_TagMallocz( size, TAG_RENDERER )
diff --git a/src/ref_public.h b/src/ref_public.h
index 6847710..e1419fd 100644
--- a/src/ref_public.h
+++ b/src/ref_public.h
@@ -71,11 +71,16 @@ typedef struct entity_s {
** misc
*/
float backlerp; // 0.0 = current, 1.0 = old
- int skinnum; // also used as RF_BEAM's palette index
+ int skinnum; // also used as RF_BEAM's palette index,
+ // -1 => use rgba
int lightstyle; // for flashing entities
float alpha; // ignore if RF_TRANSLUCENT isn't set
+#if USE_REF == REF_GL
+ color_t rgba;
+#endif
+
qhandle_t skin; // NULL for inline skin
int flags;
} entity_t;
@@ -91,9 +96,11 @@ typedef struct dlight_s {
typedef struct particle_s {
vec3_t origin;
- int color;
+ int color; // -1 => use rgba
float alpha;
- color_t rgb;
+#if USE_REF == REF_GL
+ color_t rgba;
+#endif
} particle_t;
typedef struct lightstyle_s {
@@ -139,14 +146,6 @@ typedef struct {
extern refcfg_t r_config;
-#define DRAW_COLOR_CLEAR 0
-#define DRAW_COLOR_RGB 0x00000001
-#define DRAW_COLOR_ALPHA 0x00000002
-#define DRAW_COLOR_RGBA 0x00000003
-#define DRAW_COLOR_INDEXED 0x00000004
-#define DRAW_COLOR_MASK 0x00000007
-
-
#define DRAW_CLIP_DISABLED 0
#define DRAW_CLIP_LEFT 0x00000004
#define DRAW_CLIP_RIGHT 0x00000008
@@ -190,7 +189,9 @@ void R_EndRegistration( void );
void R_RenderFrame( refdef_t *fd );
void R_LightPoint( vec3_t origin, vec3_t light );
-void R_SetColor( int flags, const color_t color );
+void R_ClearColor( void );
+void R_SetAlpha( float clpha );
+void R_SetColor( uint32_t color );
void R_SetClipRect( int flags, const clipRect_t *clip );
void R_SetScale( float *scale );
void R_DrawChar( int x, int y, int flags, int ch, qhandle_t font );
@@ -202,8 +203,8 @@ void R_DrawStretchPic( int x, int y, int w, int h, qhandle_t pic );
void R_DrawStretchPicST( int x, int y, int w, int h,
float s1, float t1, float s2, float t2, qhandle_t pic );
void R_TileClear( int x, int y, int w, int h, qhandle_t pic );
-void R_DrawFill( int x, int y, int w, int h, int c );
-void R_DrawFillEx( int x, int y, int w, int h, const color_t color );
+void R_DrawFill8( int x, int y, int w, int h, int c );
+void R_DrawFill32( int x, int y, int w, int h, uint32_t color );
// video mode and refresh state management entry points
void R_BeginFrame( void );
diff --git a/src/sw_draw.c b/src/sw_draw.c
index eabdbd3..4c18e0c 100644
--- a/src/sw_draw.c
+++ b/src/sw_draw.c
@@ -141,30 +141,15 @@ void R_InitDraw( void ) {
}
}
-void R_SetColor( int flags, const color_t color ) {
- draw.flags &= ~DRAW_COLOR_MASK;
-
- if( flags == DRAW_COLOR_CLEAR ) {
- draw.colorIndex = -1;
- return;
- }
-
- if( flags == DRAW_COLOR_ALPHA ) {
- return;
- }
-
- if( flags == DRAW_COLOR_INDEXED ) {
- draw.colorIndex = *( uint32_t * )color & 255;
- return;
- }
+void R_ClearColor( void ) {
+ draw.colorIndex = -1;
+}
- if( flags & DRAW_COLOR_RGB ) {
- draw.colorIndex = R_IndexForColor( color );
- }
- if( flags & DRAW_COLOR_ALPHA ) {
- }
+void R_SetAlpha( float alpha ) {
+}
- draw.flags |= flags;
+void R_SetColor( uint32_t color ) {
+ draw.colorIndex = R_IndexForColor( color );
}
void R_SetClipRect( int flags, const clipRect_t *clip ) {
@@ -658,7 +643,7 @@ R_DrawFill
Fills a box of pixels with a single color
=============
*/
-void R_DrawFill( int x, int y, int w, int h, int c ) {
+void R_DrawFill8( int x, int y, int w, int h, int c ) {
byte *dest;
int u, v;
@@ -683,10 +668,11 @@ void R_DrawFill( int x, int y, int w, int h, int c ) {
dest[u] = c;
}
-void R_DrawFillEx( int x, int y, int w, int h, const color_t color ) {
+void R_DrawFill32( int x, int y, int w, int h, uint32_t color ) {
int c;
byte *dest;
int u, v;
+ int alpha;
if( x + w > vid.width )
w = vid.width - x;
@@ -703,11 +689,12 @@ void R_DrawFillEx( int x, int y, int w, int h, const color_t color ) {
if( w < 0 || h < 0 )
return;
- c = color ? R_IndexForColor( color ) : 0xD7;
+ c = R_IndexForColor( color );
+ alpha = ( LittleLong( color ) >> 24 ) & 0xff;
dest = vid.buffer + y * vid.rowbytes + x;
- if( color[3] < 172 ) {
- if( color[3] > 84 ) {
+ if( alpha < 172 ) {
+ if( alpha > 84 ) {
for( v = 0; v < h; v++, dest += vid.rowbytes ) {
for( u = 0 ; u < w; u++ ) {
dest[u] = vid.alphamap[c * 256 + dest[u]];
diff --git a/src/sw_image.c b/src/sw_image.c
index aafd1b3..408836d 100644
--- a/src/sw_image.c
+++ b/src/sw_image.c
@@ -113,12 +113,13 @@ static void R_CreateNotexture( void ) {
}
}
-int R_IndexForColor( const color_t color ) {
+int R_IndexForColor( uint32_t color ) {
unsigned int r, g, b, c;
+ color_t tmp = { color };
- r = ( color[0] >> 3 ) & 31;
- g = ( color[1] >> 2 ) & 63;
- b = ( color[2] >> 3 ) & 31;
+ r = ( tmp.u8[0] >> 3 ) & 31;
+ g = ( tmp.u8[1] >> 2 ) & 63;
+ b = ( tmp.u8[2] >> 3 ) & 31;
c = r | ( g << 5 ) | ( b << 11 );
diff --git a/src/sw_local.h b/src/sw_local.h
index 2d0d283..db232ae 100644
--- a/src/sw_local.h
+++ b/src/sw_local.h
@@ -717,7 +717,7 @@ typedef struct swstate_s {
void R_IMFlatShadedQuad( vec3_t a, vec3_t b, vec3_t c, vec3_t d, int color, float alpha );
-int R_IndexForColor( const color_t color );
+int R_IndexForColor( uint32_t color );
void R_InitDraw( void );
diff --git a/src/sw_misc.c b/src/sw_misc.c
index e98aa82..0a00d04 100644
--- a/src/sw_misc.c
+++ b/src/sw_misc.c
@@ -110,7 +110,7 @@ void D_ViewChanged (void)
if ( r_newrefdef.rdflags & RDF_NOWORLDMODEL )
{
memset( d_pzbuffer, 0xff, vid.width * vid.height * sizeof( d_pzbuffer[0] ) );
- R_DrawFill( r_newrefdef.x, r_newrefdef.y, r_newrefdef.width, r_newrefdef.height, /*( int ) sw_clearcolor->value & 0xff*/0 );
+ R_DrawFill8( r_newrefdef.x, r_newrefdef.y, r_newrefdef.width, r_newrefdef.height, /*( int ) sw_clearcolor->value & 0xff*/0 );
}
D_Patch ();
diff --git a/src/ui_atoms.c b/src/ui_atoms.c
index 13eb852..46e6c15 100644
--- a/src/ui_atoms.c
+++ b/src/ui_atoms.c
@@ -313,21 +313,14 @@ qboolean UI_CursorInRect( vrect_t *rect ) {
return qtrue;
}
-void UI_DrawString( int x, int y, const color_t color, int flags, const char *string ) {
- if( color ) {
- R_SetColor( DRAW_COLOR_RGBA, color );
- }
-
+void UI_DrawString( int x, int y, int flags, const char *string ) {
if( ( flags & UI_CENTER ) == UI_CENTER ) {
x -= strlen( string ) * CHAR_WIDTH / 2;
} else if( flags & UI_RIGHT ) {
x -= strlen( string ) * CHAR_WIDTH;
}
-
+
R_DrawString( x, y, flags, MAX_STRING_CHARS, string, uis.fontHandle );
- if( color ) {
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
- }
}
void UI_DrawChar( int x, int y, int flags, int ch ) {
@@ -345,20 +338,21 @@ void UI_StringDimensions( vrect_t *rc, int flags, const char *string ) {
}
}
-void UI_DrawRect( const vrect_t *rc, int border, int color ) {
- R_DrawFill( rc->x, rc->y, border, rc->height, color ); // left
- R_DrawFill( rc->x + rc->width - border, rc->y, border, rc->height, color ); // right
- R_DrawFill( rc->x + border, rc->y, rc->width - border * 2, border, color ); // top
- R_DrawFill( rc->x + border, rc->y + rc->height - border, rc->width - border * 2, border, color ); // bottom
+void UI_DrawRect8( const vrect_t *rc, int border, int c ) {
+ R_DrawFill8( rc->x, rc->y, border, rc->height, c ); // left
+ R_DrawFill8( rc->x + rc->width - border, rc->y, border, rc->height, c ); // right
+ R_DrawFill8( rc->x + border, rc->y, rc->width - border * 2, border, c ); // top
+ R_DrawFill8( rc->x + border, rc->y + rc->height - border, rc->width - border * 2, border, c ); // bottom
}
-void UI_DrawRectEx( const vrect_t *rc, int border, const color_t color ) {
- R_DrawFillEx( rc->x, rc->y, border, rc->height, color ); // left
- R_DrawFillEx( rc->x + rc->width - border, rc->y, border, rc->height, color ); // right
- R_DrawFillEx( rc->x + border, rc->y, rc->width - border * 2, border, color ); // top
- R_DrawFillEx( rc->x + border, rc->y + rc->height - border, rc->width - border * 2, border, color ); // bottom
+#if 0
+void UI_DrawRect32( const vrect_t *rc, int border, uint32_t color ) {
+ R_DrawFill32( rc->x, rc->y, border, rc->height, color ); // left
+ R_DrawFill32( rc->x + rc->width - border, rc->y, border, rc->height, color ); // right
+ R_DrawFill32( rc->x + border, rc->y, rc->width - border * 2, border, color ); // top
+ R_DrawFill32( rc->x + border, rc->y + rc->height - border, rc->width - border * 2, border, color ); // bottom
}
-
+#endif
//=============================================================================
/* Menu Subsystem */
@@ -426,7 +420,7 @@ void UI_Draw( int realtime ) {
return;
}
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ R_ClearColor();
#if USE_REF == REF_SOFT
R_SetClipRect( DRAW_CLIP_MASK, &uis.clipRect );
#else
@@ -458,7 +452,7 @@ void UI_Draw( int realtime ) {
}
if( ui_debug->integer ) {
- UI_DrawString( uis.width - 4, 4, NULL, UI_RIGHT,
+ UI_DrawString( uis.width - 4, 4, UI_RIGHT,
va( "%3i %3i", uis.mouseCoords[0], uis.mouseCoords[1] ) );
}
@@ -475,7 +469,7 @@ void UI_Draw( int realtime ) {
#else
R_SetScale( NULL );
#endif
- R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ R_ClearColor();
}
void UI_StartSound( menuSound_t sound ) {
@@ -631,11 +625,11 @@ qboolean UI_Init( void ) {
uis.bitmapCursors[i] = R_RegisterPic( buffer );
}
- Vector4Set( uis.color.background, 0, 0, 0, 255 );
- Vector4Set( uis.color.normal, 15, 128, 235, 100 );
- Vector4Set( uis.color.active, 15, 128, 235, 100 );
- Vector4Set( uis.color.selection, 15, 128, 235, 100 );
- Vector4Set( uis.color.disabled, 127, 127, 127, 255 );
+ uis.color.background.u32 = MakeColor( 0, 0, 0, 255 );
+ uis.color.normal.u32 = MakeColor( 15, 128, 235, 100 );
+ uis.color.active.u32 = MakeColor( 15, 128, 235, 100 );
+ uis.color.selection.u32 = MakeColor( 15, 128, 235, 100 );
+ uis.color.disabled.u32 = MakeColor( 127, 127, 127, 255 );
strcpy( uis.weaponModel, "w_railgun.md2" );
diff --git a/src/ui_demos.c b/src/ui_demos.c
index 9df4739..dd322b9 100644
--- a/src/ui_demos.c
+++ b/src/ui_demos.c
@@ -522,7 +522,7 @@ static void Draw( menuFrameWork_t *self ) {
Menu_Draw( self );
if( uis.width >= 640 ) {
UI_DrawString( uis.width, uis.height - CHAR_HEIGHT,
- NULL, UI_RIGHT, m_demos.status );
+ UI_RIGHT, m_demos.status );
}
}
@@ -589,7 +589,7 @@ void M_Menu_Demos( void ) {
m_demos.menu.keydown = Keydown;
m_demos.menu.free = Free;
m_demos.menu.image = uis.backgroundHandle;
- FastColorCopy( uis.color.background, m_demos.menu.color );
+ m_demos.menu.color.u32 = uis.color.background.u32;
m_demos.list.generic.type = MTYPE_LIST;
m_demos.list.generic.flags = QMF_HASFOCUS;
diff --git a/src/ui_local.h b/src/ui_local.h
index 6bdd269..ef860c3 100644
--- a/src/ui_local.h
+++ b/src/ui_local.h
@@ -311,12 +311,10 @@ qboolean UI_CursorInRect( vrect_t *rect );
void *UI_FormatColumns( int extrasize, ... ) q_sentinel;
char *UI_GetColumn( char *s, int n );
void UI_AddToServerList( const serverStatus_t *status );
-void UI_DrawLoading( int realtime );
-void UI_SetupDefaultBanner( menuStatic_t *banner, const char *name );
-void UI_DrawString( int x, int y, const color_t color, int flags, const char *string );
+void UI_DrawString( int x, int y, int flags, const char *string );
void UI_DrawChar( int x, int y, int flags, int ch );
-void UI_DrawRect( const vrect_t *rect, int border, int color );
-void UI_DrawRectEx( const vrect_t *rect, int border, const color_t color );
+void UI_DrawRect8( const vrect_t *rect, int border, int c );
+//void UI_DrawRect32( const vrect_t *rect, int border, uint32_t color );
void UI_StringDimensions( vrect_t *rc, int flags, const char *string );
void UI_LoadScript( void );
diff --git a/src/ui_menu.c b/src/ui_menu.c
index 2770cc0..7f2f50c 100644
--- a/src/ui_menu.c
+++ b/src/ui_menu.c
@@ -76,8 +76,7 @@ static void Action_Draw( menuAction_t *a ) {
}
}
- UI_DrawString( a->generic.x, a->generic.y, NULL,
- flags, a->generic.name );
+ UI_DrawString( a->generic.x, a->generic.y, flags, a->generic.name );
}
/*
@@ -115,9 +114,13 @@ Static_Draw
=================
*/
static void Static_Draw( menuStatic_t *s ) {
- UI_DrawString( s->generic.x, s->generic.y,
- ( s->generic.flags & QMF_CUSTOM_COLOR ) ? s->generic.color : NULL,
- s->generic.uiFlags, s->generic.name );
+ if( s->generic.flags & QMF_CUSTOM_COLOR ) {
+ R_SetColor( s->generic.color.u32 );
+ }
+ UI_DrawString( s->generic.x, s->generic.y, s->generic.uiFlags, s->generic.name );
+ if( s->generic.flags & QMF_CUSTOM_COLOR ) {
+ R_ClearColor();
+ }
}
/*
@@ -193,10 +196,8 @@ Keybind_Draw
*/
static void Keybind_Draw( menuKeybind_t *k ) {
char string[MAX_STRING_CHARS];
- byte *color;
int flags;
- color = NULL;
flags = UI_ALTCOLOR;
if( k->generic.flags & QMF_HASFOCUS ) {
/*if( k->generic.parent->keywait ) {
@@ -206,12 +207,12 @@ static void Keybind_Draw( menuKeybind_t *k ) {
}
} else {
if( k->generic.parent->keywait ) {
- color = uis.color.disabled;
+ R_SetColor( uis.color.disabled.u32 );
flags = 0;
}
}
- UI_DrawString( k->generic.x + LCOLUMN_OFFSET, k->generic.y, color,
+ UI_DrawString( k->generic.x + LCOLUMN_OFFSET, k->generic.y,
k->generic.uiFlags | UI_RIGHT | flags, k->generic.name );
if( k->altbinding[0] ) {
@@ -222,8 +223,10 @@ static void Keybind_Draw( menuKeybind_t *k ) {
strcpy( string, "???" );
}
- UI_DrawString( k->generic.x + RCOLUMN_OFFSET, k->generic.y, color,
+ UI_DrawString( k->generic.x + RCOLUMN_OFFSET, k->generic.y,
k->generic.uiFlags | UI_LEFT, string );
+
+ R_ClearColor();
}
static void Keybind_Push( menuKeybind_t *k ) {
@@ -377,24 +380,24 @@ Field_Draw
*/
static void Field_Draw( menuField_t *f ) {
int flags = f->generic.uiFlags;
- byte *color = uis.color.normal;
+ uint32_t color = uis.color.normal.u32;
if( f->generic.flags & QMF_HASFOCUS ) {
flags |= UI_DRAWCURSOR;
- color = uis.color.active;
+ color = uis.color.active.u32;
}
if( f->generic.name ) {
- UI_DrawString( f->generic.x + LCOLUMN_OFFSET, f->generic.y, NULL,
+ UI_DrawString( f->generic.x + LCOLUMN_OFFSET, f->generic.y,
f->generic.uiFlags | UI_RIGHT | UI_ALTCOLOR, f->generic.name );
- R_DrawFillEx( f->generic.x + RCOLUMN_OFFSET, f->generic.y - 1,
+ R_DrawFill32( f->generic.x + RCOLUMN_OFFSET, f->generic.y - 1,
f->field.visibleChars * CHAR_WIDTH, CHAR_HEIGHT + 2, color );
IF_Draw( &f->field, f->generic.x + RCOLUMN_OFFSET, f->generic.y,
flags, uis.fontHandle );
} else {
- R_DrawFillEx( f->generic.rect.x, f->generic.rect.y - 1,
+ R_DrawFill32( f->generic.rect.x, f->generic.rect.y - 1,
f->generic.rect.width, CHAR_HEIGHT + 2, color );
IF_Draw( &f->field, f->generic.rect.x, f->generic.rect.y,
@@ -557,7 +560,7 @@ SpinControl_Draw
=================
*/
static void SpinControl_Draw( menuSpinControl_t *s ) {
- UI_DrawString( s->generic.x + LCOLUMN_OFFSET, s->generic.y, NULL,
+ UI_DrawString( s->generic.x + LCOLUMN_OFFSET, s->generic.y,
s->generic.uiFlags | UI_RIGHT | UI_ALTCOLOR, s->generic.name );
if( s->generic.flags & QMF_HASFOCUS ) {
@@ -567,7 +570,7 @@ static void SpinControl_Draw( menuSpinControl_t *s ) {
}
}
- UI_DrawString( s->generic.x + RCOLUMN_OFFSET, s->generic.y, NULL,
+ UI_DrawString( s->generic.x + RCOLUMN_OFFSET, s->generic.y,
s->generic.uiFlags, s->itemnames[s->curvalue] );
}
@@ -1022,7 +1025,7 @@ static void MenuList_DrawString( int x, int y, int flags,
}
R_SetClipRect( DRAW_CLIP_RIGHT|DRAW_CLIP_LEFT, &rc );
- UI_DrawString( x, y + 1, NULL, column->uiFlags | flags, string );
+ UI_DrawString( x, y + 1, column->uiFlags | flags, string );
#if USE_REF == REF_SOFT
R_SetClipRect( DRAW_CLIP_MASK, &uis.clipRect );
#else
@@ -1053,15 +1056,15 @@ static void MenuList_Draw( menuList_t *l ) {
xx = x;
for( j = 0; j < l->numcolumns; j++ ) {
int flags = UI_ALTCOLOR;
- byte *color = uis.color.normal;
+ uint32_t color = uis.color.normal.u32;
if( l->sortcol == j && l->sortdir ) {
flags = 0;
if( l->generic.flags & QMF_HASFOCUS ) {
- color = uis.color.active;
+ color = uis.color.active.u32;
}
}
- R_DrawFillEx( xx, y, l->columns[j].width - 1,
+ R_DrawFill32( xx, y, l->columns[j].width - 1,
MLIST_SPACING - 1, color );
if( l->columns[j].name ) {
@@ -1082,8 +1085,8 @@ static void MenuList_Draw( menuList_t *l ) {
// draw scrollbar background
if( !( l->mlFlags & MLF_HIDE_BACKGROUND ) ) {
- R_DrawFillEx( x + width, yy, MLIST_SCROLLBAR_WIDTH - 1,
- barHeight, uis.color.normal );
+ R_DrawFill32( x + width, yy, MLIST_SCROLLBAR_WIDTH - 1,
+ barHeight, uis.color.normal.u32 );
}
if( l->numItems > l->maxItems ) {
@@ -1095,25 +1098,25 @@ static void MenuList_Draw( menuList_t *l ) {
}
// draw scrollbar thumb
- R_DrawFillEx( x + width,
+ R_DrawFill32( x + width,
yy + Q_rint( barHeight * prestepFrac ),
MLIST_SCROLLBAR_WIDTH - 1,
Q_rint( barHeight * pageFrac ),
- uis.color.selection );
+ uis.color.selection.u32 );
}
xx = x;
for( j = 0; j < l->numcolumns; j++ ) {
- byte *color = uis.color.normal;
+ uint32_t color = uis.color.normal.u32;
if( l->sortcol == j && l->sortdir ) {
if( l->generic.flags & QMF_HASFOCUS ) {
- color = uis.color.active;
+ color = uis.color.active.u32;
}
}
- R_DrawFillEx( xx, y, l->columns[j].width - 1,
+ R_DrawFill32( xx, y, l->columns[j].width - 1,
height, color );
-
+
xx += l->columns[j].width;
}
@@ -1124,8 +1127,8 @@ static void MenuList_Draw( menuList_t *l ) {
if( !( l->generic.flags & QMF_DISABLED ) && i == l->curvalue ) {
xx = x;
for( j = 0; j < l->numcolumns; j++ ) {
- R_DrawFillEx( xx, yy, l->columns[j].width - 1,
- MLIST_SPACING, uis.color.selection );
+ R_DrawFill32( xx, yy, l->columns[j].width - 1,
+ MLIST_SPACING, uis.color.selection.u32 );
xx += l->columns[j].width;
}
}
@@ -1254,7 +1257,7 @@ static void Slider_Draw( menuSlider_t *s ) {
}
}
- UI_DrawString( s->generic.x + LCOLUMN_OFFSET, s->generic.y, NULL,
+ UI_DrawString( s->generic.x + LCOLUMN_OFFSET, s->generic.y,
flags | UI_RIGHT | UI_ALTCOLOR, s->generic.name );
UI_DrawChar( s->generic.x + RCOLUMN_OFFSET, s->generic.y, flags | UI_LEFT, 128 );
@@ -1295,7 +1298,7 @@ Separator_Draw
*/
static void Separator_Draw( menuSeparator_t *s ) {
if( s->generic.name )
- UI_DrawString( s->generic.x, s->generic.y, NULL, UI_RIGHT, s->generic.name );
+ UI_DrawString( s->generic.x, s->generic.y, UI_RIGHT, s->generic.name );
}
/*
@@ -1659,15 +1662,15 @@ void Menu_Draw( menuFrameWork_t *menu ) {
R_DrawStretchPic( 0, menu->y1, uis.width,
menu->y2 - menu->y1, menu->image );
} else {
- R_DrawFillEx( 0, menu->y1, uis.width,
- menu->y2 - menu->y1, menu->color );
+ R_DrawFill32( 0, menu->y1, uis.width,
+ menu->y2 - menu->y1, menu->color.u32 );
}
//
// draw title bar
//
if( menu->title ) {
- UI_DrawString( uis.width / 2, menu->y1, NULL,
+ UI_DrawString( uis.width / 2, menu->y1,
UI_CENTER|UI_ALTCOLOR, menu->title );
}
@@ -1732,7 +1735,7 @@ void Menu_Draw( menuFrameWork_t *menu ) {
}
if( ui_debug->integer ) {
- UI_DrawRect( &(( menuCommon_t * )item)->rect, 1, 223 );
+ UI_DrawRect8( &(( menuCommon_t * )item)->rect, 1, 223 );
}
}
@@ -1740,8 +1743,8 @@ void Menu_Draw( menuFrameWork_t *menu ) {
// draw status bar
//
if( menu->status ) {
- R_DrawFill( 0, menu->y2 - CHAR_HEIGHT, uis.width, CHAR_HEIGHT, 4 );
- UI_DrawString( uis.width / 2, menu->y2 - CHAR_HEIGHT, NULL,
+ R_DrawFill8( 0, menu->y2 - CHAR_HEIGHT, uis.width, CHAR_HEIGHT, 4 );
+ UI_DrawString( uis.width / 2, menu->y2 - CHAR_HEIGHT,
UI_CENTER, menu->status );
}
}
diff --git a/src/ui_multiplayer.c b/src/ui_multiplayer.c
index 70b73ad..b97dddf 100644
--- a/src/ui_multiplayer.c
+++ b/src/ui_multiplayer.c
@@ -384,8 +384,8 @@ void M_Menu_Servers( void ) {
m_join.menu.size = Size;
m_join.menu.keydown = Keydown;
m_join.menu.free = Free;
- m_join.menu.image = uis.backgroundHandle;
- FastColorCopy( uis.color.background, m_join.menu.color );
+ m_join.menu.image = uis.backgroundHandle;
+ m_join.menu.color.u32 = uis.color.background.u32;
//
// server list
diff --git a/src/ui_playerconfig.c b/src/ui_playerconfig.c
index ecf46b4..ac41268 100644
--- a/src/ui_playerconfig.c
+++ b/src/ui_playerconfig.c
@@ -257,7 +257,7 @@ void M_Menu_PlayerConfig( void ) {
m_player.menu.draw = Draw;
m_player.menu.free = Free;
m_player.menu.image = uis.backgroundHandle;
- FastColorCopy( uis.color.background, m_player.menu.color );
+ m_player.menu.color.u32 = uis.color.background.u32;
m_player.entities[0].flags = RF_FULLBRIGHT;
VectorCopy( angles, m_player.entities[0].angles );
diff --git a/src/ui_script.c b/src/ui_script.c
index e656471..772073b 100644
--- a/src/ui_script.c
+++ b/src/ui_script.c
@@ -312,9 +312,9 @@ static void Parse_Blank( menuFrameWork_t *menu ) {
static void Parse_Background( menuFrameWork_t *menu ) {
char *s = Cmd_Argv( 1 );
- if( SCR_ParseColor( s, menu->color ) ) {
+ if( SCR_ParseColor( s, &menu->color ) ) {
menu->image = 0;
- if( menu->color[3] != 255 ) {
+ if( menu->color.u8[3] != 255 ) {
menu->transparent = qtrue;
}
} else {
@@ -335,13 +335,13 @@ static void Parse_Color( void ) {
c = Cmd_Argv( 2 );
if( !strcmp( s, "normal" ) ) {
- SCR_ParseColor( c, uis.color.normal );
+ SCR_ParseColor( c, &uis.color.normal );
} else if( !strcmp( s, "active" ) ) {
- SCR_ParseColor( c, uis.color.active );
+ SCR_ParseColor( c, &uis.color.active );
} else if( !strcmp( s, "selection" ) ) {
- SCR_ParseColor( c, uis.color.selection );
+ SCR_ParseColor( c, &uis.color.selection );
} else if( !strcmp( s, "disabled" ) ) {
- SCR_ParseColor( c, uis.color.disabled );
+ SCR_ParseColor( c, &uis.color.disabled );
} else {
Com_Printf( "Unknown state '%s'\n", s );
}
@@ -473,7 +473,7 @@ static qboolean Parse_File( const char *path, int depth ) {
menu->pop = Menu_Pop;
menu->free = Menu_Free;
menu->image = uis.backgroundHandle;
- FastColorCopy( uis.color.background, menu->color );
+ menu->color.u32 = uis.color.background.u32;
} else if( !strcmp( cmd, "include" ) ) {
char *s = Cmd_Argv( 1 );
if( !*s ) {
@@ -490,7 +490,7 @@ static qboolean Parse_File( const char *path, int depth ) {
} else if( !strcmp( cmd, "background" ) ) {
char *s = Cmd_Argv( 1 );
- if( SCR_ParseColor( s, uis.color.background ) ) {
+ if( SCR_ParseColor( s, &uis.color.background ) ) {
uis.backgroundHandle = 0;
} else {
uis.backgroundHandle = R_RegisterPic( s );