/* ================ CG_DrawRotatedPic Coordinates are 640*480 virtual values ================= */ void CG_DrawRotatedPic(float x, float y, float width, float height, qhandle_t hShader, float angle) { CG_AdjustFrom640(&x, &y, &width, &height); trap_R_DrawRotatedPic(x, y, width, height, 0, 0, 1, 1, hShader, angle); }
void Image::think(int ms) { if (!element_attrs.active) { return; } // We think first think_fun(ms); // Whenever the image has been modified or we get a new screen // modification, then we need to re-evaluate the image if (image_attrs.src_handle == -1 || global::screen_attrs.modified) { Com_Printf("Image::think(%d) for %s - Source handle needs updating to %s\n", ms, name, image_attrs.src.c_str()); image_attrs.src_handle = trap_R_RegisterShaderNoMip(image_attrs.src.c_str()); if (!image_attrs.src_handle) { Com_Warning("Image::think(%d) for %s - The image could not be loaded.\n", ms, name, image_attrs.src.c_str()); } } if (!image_attrs.src_handle) { return; } // Draw the image if (element_attrs.modified || global::screen_attrs.modified) { Screen_attributes& screen = global::screen_attrs; image_attrs.scaled_x = element_attrs.x * screen.scale_x; image_attrs.scaled_y = element_attrs.y * screen.scale_y; image_attrs.scaled_w = element_attrs.width * screen.scale_x; image_attrs.scaled_h = element_attrs.height * screen.scale_y; } if (image_attrs.angle != 0.0f) { // Draw the actual image, just rotated trap_R_DrawRotatedPic(image_attrs.scaled_x, image_attrs.scaled_y, image_attrs.scaled_w, image_attrs.scaled_h, image_attrs.s1, image_attrs.t1, image_attrs.s2, image_attrs.t2, image_attrs.src_handle, image_attrs.angle); } else { // Draw the actual image trap_R_DrawStretchPic(image_attrs.scaled_x, image_attrs.scaled_y, image_attrs.scaled_w, image_attrs.scaled_h, image_attrs.s1, image_attrs.t1, image_attrs.s2, image_attrs.t2, image_attrs.src_handle); } element_attrs.modified = false; }
void cdraw::Line(float startX, float startY, float endX, float endY, float *colour, float width) { float sizeX = endX-startX; float sizeY = endY-startY; float size = sqrt((sizeX*sizeX)+(sizeY*sizeY)); float x = (startX+(sizeX/2))-(size/2); float y = startY+(sizeY/2); float angle = RAD2DEG(atan(sizeY/sizeX)); trap_R_DrawRotatedPic(x, y, size, width, 2, 2, 0, 0, angle, colour, bot.shaders.White); }
/* ================ CG_DrawMinimapObject ================ */ static void CG_DrawMinimapObject( const qhandle_t image, const vec3_t pos3d, const float angle, const float scale, const float texSize, const float alpha ) { vec2_t offset; float x, y, wh, realScale, realAngle; realAngle = CG_WorldToMinimapAngle( angle ); realScale = CG_WorldToMinimapScale( scale ); CG_WorldToMinimap( pos3d, offset ); x = - texSize/2 * realScale + offset[0]; y = - texSize/2 * realScale + offset[1]; wh = texSize * realScale; //Handle teamcolor + transparency currentMinimapColor[3] = alpha; trap_R_SetColor( currentMinimapColor ); trap_R_DrawRotatedPic( x, y, wh, wh, 0.0, 0.0, 1.0, 1.0, image, realAngle ); }
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(); }
void cdraw::ShaderRotate(float x, float y, float width, float height, float *colour, LPSTR shader, float rotate) { trap_R_DrawRotatedPic(x, y, width, height, 0, 0, 1, 1, rotate, colour, shader); }
void cdraw::Gradient(float x, float y, float width, float height, float *colour1, float *colour2, bool horizontal) { float fAdd = (horizontal?0:width/2-height/2); trap_R_DrawRotatedPic( x, y, width, height, 0, 0, 1, 1, 0, colour2, bot.shaders.White ); trap_R_DrawRotatedPic( x+fAdd, y-fAdd, (horizontal?width:height), (horizontal?height:width), 0.5f, 0, 1, 1, (horizontal ? 0.0f : 90.0f), colour1, bot.shaders.Gradient ); }
void cdraw::Box(float x, float y, float width, float height, float *colour, float rotate) { trap_R_DrawRotatedPic(x, y, width, height, 0, 0, 0, 1, rotate, colour, bot.shaders.White); }
static void CG_DrawBeacon( cbeacon_t *b ) { float angle; vec4_t color; if( b->type == BCT_TAG && b->clamped ) return; Vector4Copy( b->color, color ); // display important beacons at 100% opacity if( !( BG_Beacon( b->type )->flags & BCF_IMPORTANT ) ) color[ 3 ] *= cgs.bc.hudAlpha; 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, qtrue ) ); 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; 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/100 ); 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_SetColor( NULL ); }