/* ================ CG_DrawRect Coordinates are 640*480 virtual values ================= */ void CG_DrawRect( float x, float y, float width, float height, float size, const Color::Color& color ) { trap_R_SetColor( color ); CG_DrawTopBottom( x, y, width, height, size ); CG_DrawSides( x, y, width, height, size ); trap_R_ClearColor(); }
/* ================ CG_FillRect Coordinates are 640*480 virtual values ================= */ void CG_FillRect( float x, float y, float width, float height, const Color::Color& color ) { trap_R_SetColor( color ); CG_AdjustFrom640( &x, &y, &width, &height ); trap_R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, cgs.media.whiteShader ); trap_R_ClearColor(); }
/* ================ CG_DrawFadePic Coordinates are 640*480 virtual values ================= */ void CG_DrawFadePic( float x, float y, float width, float height, const Color::Color& fcolor, const Color::Color& tcolor, float amount, qhandle_t hShader ) { CG_AdjustFrom640( &x, &y, &width, &height ); Color::Color finalcolor = Color::Blend( fcolor, tcolor, amount / 100 ); trap_R_SetColor( finalcolor ); trap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader ); trap_R_ClearColor(); }
/* ================= CG_Draw2D ================= */ static void CG_Draw2D() { int i; if ( cg_draw2D.integer == 0 ) { return; } if ( cg.snap->ps.pm_type == PM_INTERMISSION ) { CG_DrawIntermission(); return; } if ( cg.snap->ps.persistant[ PERS_SPECSTATE ] == SPECTATOR_NOT && cg.snap->ps.stats[ STAT_HEALTH ] > 0 && !cg.zoomed ) { CG_DrawBuildableStatus(); } // get an up-to-date list of beacons CG_RunBeacons(); // draw beacons on HUD for( i = 0; i < cg.beaconCount; i++ ) CG_DrawBeacon( cg.beacons[ i ] ); CombatFeedback::DrawDamageIndicators(); if ( cg.zoomed ) { Color::Color black = { 0.f, 0.f, 0.f, 0.5f }; trap_R_DrawStretchPic( ( cgs.glconfig.vidWidth / 2 ) - ( cgs.glconfig.vidHeight / 2 ), 0, cgs.glconfig.vidHeight, cgs.glconfig.vidHeight, 0, 0, 1, 1, cgs.media.scopeShader ); trap_R_SetColor( black ); trap_R_DrawStretchPic( 0, 0, ( cgs.glconfig.vidWidth / 2 ) - ( cgs.glconfig.vidHeight / 2 ), cgs.glconfig.vidHeight, 0, 0, 1, 1, cgs.media.whiteShader ); trap_R_DrawStretchPic( cgs.glconfig.vidWidth - ( ( cgs.glconfig.vidWidth / 2 ) - ( cgs.glconfig.vidHeight / 2 ) ), 0, ( cgs.glconfig.vidWidth / 2 ) - ( cgs.glconfig.vidHeight / 2 ), cgs.glconfig.vidHeight, 0, 0, 1, 1, cgs.media.whiteShader ); trap_R_ClearColor(); } }
/* =============== CG_PainBlend =============== */ static void CG_PainBlend() { int damage; float damageAsFracOfMax; qhandle_t shader = cgs.media.viewBloodShader; float x, y, w, h; float s1, t1, s2, t2; if ( cg.snap->ps.persistant[ PERS_SPECSTATE ] != SPECTATOR_NOT || cg.intermissionStarted ) { return; } damage = cg.lastHealth - cg.snap->ps.stats[ STAT_HEALTH ]; if ( damage < 0 ) { damage = 0; } damageAsFracOfMax = ( float ) damage / cg.snap->ps.stats[ STAT_MAX_HEALTH ]; cg.lastHealth = cg.snap->ps.stats[ STAT_HEALTH ]; cg.painBlendValue += damageAsFracOfMax * cg_painBlendScale.value; if ( cg.painBlendValue > 0.0f ) { cg.painBlendValue -= ( cg.frametime / 1000.0f ) * cg_painBlendDownRate.value; } if ( cg.painBlendValue > 1.0f ) { cg.painBlendValue = 1.0f; } else if ( cg.painBlendValue <= 0.0f ) { cg.painBlendValue = 0.0f; return; } Color::Color color; if ( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_ALIENS ) { color = { 0.43f, 0.8f, 0.37f }; } else if ( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_HUMANS ) { color = { 0.8f, 0.0f, 0.0f }; } if ( cg.painBlendValue > cg.painBlendTarget ) { cg.painBlendTarget += ( cg.frametime / 1000.0f ) * cg_painBlendUpRate.value; } else if ( cg.painBlendValue < cg.painBlendTarget ) { cg.painBlendTarget = cg.painBlendValue; } if ( cg.painBlendTarget > cg_painBlendMax.value ) { cg.painBlendTarget = cg_painBlendMax.value; } color.SetAlpha( cg.painBlendTarget ); trap_R_SetColor( color ); //left x = 0.0f; y = 0.0f; w = PAINBLEND_BORDER * 640.0f; h = 480.0f; CG_AdjustFrom640( &x, &y, &w, &h ); s1 = 0.0f; t1 = 0.0f; s2 = PAINBLEND_BORDER; t2 = 1.0f; CG_ScalePainBlendTCs( &s1, &t1, &s2, &t2 ); trap_R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, shader ); //right x = 640.0f - ( PAINBLEND_BORDER * 640.0f ); y = 0.0f; w = PAINBLEND_BORDER * 640.0f; h = 480.0f; CG_AdjustFrom640( &x, &y, &w, &h ); s1 = 1.0f - PAINBLEND_BORDER; t1 = 0.0f; s2 = 1.0f; t2 = 1.0f; CG_ScalePainBlendTCs( &s1, &t1, &s2, &t2 ); trap_R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, shader ); //top x = PAINBLEND_BORDER * 640.0f; y = 0.0f; w = 640.0f - ( 2 * PAINBLEND_BORDER * 640.0f ); h = PAINBLEND_BORDER * 480.0f; CG_AdjustFrom640( &x, &y, &w, &h ); s1 = PAINBLEND_BORDER; t1 = 0.0f; s2 = 1.0f - PAINBLEND_BORDER; t2 = PAINBLEND_BORDER; CG_ScalePainBlendTCs( &s1, &t1, &s2, &t2 ); trap_R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, shader ); //bottom x = PAINBLEND_BORDER * 640.0f; y = 480.0f - ( PAINBLEND_BORDER * 480.0f ); w = 640.0f - ( 2 * PAINBLEND_BORDER * 640.0f ); h = PAINBLEND_BORDER * 480.0f; CG_AdjustFrom640( &x, &y, &w, &h ); s1 = PAINBLEND_BORDER; t1 = 1.0f - PAINBLEND_BORDER; s2 = 1.0f - PAINBLEND_BORDER; t2 = 1.0f; CG_ScalePainBlendTCs( &s1, &t1, &s2, &t2 ); trap_R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, shader ); trap_R_ClearColor(); }
static void CG_DrawBeacon( cbeacon_t *b ) { float angle; // Don't draw clamped beacons for tags, except for enemy players. if( b->type == BCT_TAG && b->clamped && !( ( b->flags & EF_BC_ENEMY ) && ( b->flags & EF_BC_TAG_PLAYER ) ) ) return; Color::Color color = b->color; if( !( BG_Beacon( b->type )->flags & BCF_IMPORTANT ) ) color.SetAlpha( color.Alpha() * cgs.bc.hudAlpha ); else color.SetAlpha( color.Alpha() * cgs.bc.hudAlphaImportant ); trap_R_SetColor( color ); trap_R_DrawStretchPic( b->pos[ 0 ] - b->size/2, b->pos[ 1 ] - b->size/2, b->size, b->size, 0, 0, 1, 1, CG_BeaconIcon( b ) ); if( b->flags & EF_BC_DYING ) trap_R_DrawStretchPic( b->pos[ 0 ] - b->size/2 * 1.3, b->pos[ 1 ] - b->size/2 * 1.3, b->size * 1.3, b->size * 1.3, 0, 0, 1, 1, cgs.media.beaconNoTarget ); if ( b->clamped ) trap_R_DrawRotatedPic( b->pos[ 0 ] - b->size/2 * 1.5, b->pos[ 1 ] - b->size/2 * 1.5, b->size * 1.5, b->size * 1.5, 0, 0, 1, 1, cgs.media.beaconIconArrow, 270.0 - ( angle = atan2( b->clamp_dir[ 1 ], b->clamp_dir[ 0 ] ) ) * 180 / M_PI ); if( b->type == BCT_TIMER ) { int num; num = ( BEACON_TIMER_TIME + b->ctime - cg.time ) / 100; if( num > 0 ) { float h, tw; const char *p; vec2_t pos, dir, rect[ 2 ]; int i, l, frame; h = b->size * 0.4; p = va( "%d", num ); l = strlen( p ); tw = h * l; if( !b->clamped ) { pos[ 0 ] = b->pos[ 0 ]; pos[ 1 ] = b->pos[ 1 ] + b->size/2 + h/2; } else { rect[ 0 ][ 0 ] = b->pos[ 0 ] - b->size/2 - tw/2; rect[ 1 ][ 0 ] = b->pos[ 0 ] + b->size/2 + tw/2; rect[ 0 ][ 1 ] = b->pos[ 1 ] - b->size/2 - h/2; rect[ 1 ][ 1 ] = b->pos[ 1 ] + b->size/2 + h/2; for( i = 0; i < 2; i++ ) dir[ i ] = - b->clamp_dir[ i ]; ProjectPointOntoRectangleOutwards( pos, b->pos, dir, (const vec2_t*)rect ); } pos[ 0 ] -= tw/2; pos[ 1 ] -= h/2; for( i = 0; i < l; i++ ) { if( p[ i ] >= '0' && p[ i ] <= '9' ) frame = p[ i ] - '0'; else if( p[ i ] == '-' ) frame = STAT_MINUS; else frame = -1; if( frame != -1 ) trap_R_DrawStretchPic( pos[ 0 ], pos[ 1 ], h, h, 0, 0, 1, 1, cgs.media.numberShaders[ frame ] ); pos[ 0 ] += h; } } } trap_R_ClearColor(); }