Remove draw_translucently in draw2DImage

This commit is contained in:
Benau 2023-01-11 11:27:43 +08:00
parent a85bf04b1c
commit ab3defb424
4 changed files with 15 additions and 23 deletions

View File

@ -338,26 +338,12 @@ void draw2DImage(const video::ITexture* texture,
const core::rect<s32>& sourceRect,
const core::rect<s32>* clip_rect,
const video::SColor* const colors,
bool use_alpha_channel_of_texture,
bool draw_translucently)
bool use_alpha_channel_of_texture)
{
video::SColor translucence[4] =
{
(unsigned)-1, (unsigned)-1, (unsigned)-1, (unsigned)-1
};
for (unsigned i = 0; i < 4; i++)
{
if (colors)
translucence[i] = colors[i];
if (draw_translucently)
translucence[i].setAlpha(128);
}
if (!CVS->isGLSL())
{
irr_driver->getVideoDriver()->draw2DImage(texture, destRect, sourceRect,
clip_rect, draw_translucently ? translucence : colors,
use_alpha_channel_of_texture);
clip_rect, colors, use_alpha_channel_of_texture);
return;
}
@ -390,10 +376,9 @@ void draw2DImage(const video::ITexture* texture,
(s32)render_target_size.Height - clip_rect->LowerRightCorner.Y,
clip_rect->getWidth(), clip_rect->getHeight());
}
if (draw_translucently || colors)
if (colors)
{
drawTexColoredQuad(texture, draw_translucently ? translucence : colors,
width, height, center_pos_x,
drawTexColoredQuad(texture, colors, width, height, center_pos_x,
center_pos_y, tex_center_pos_x, tex_center_pos_y,
tex_width, tex_height);
}

View File

@ -49,7 +49,7 @@ void draw2DImage(const irr::video::ITexture* texture,
const irr::core::rect<irr::s32>& sourceRect,
const irr::core::rect<irr::s32>* clipRect,
const irr::video::SColor* const colors,
bool useAlphaChannelOfTexture, bool draw_translucently = false);
bool useAlphaChannelOfTexture);
void draw2DImageRotationColor(irr::video::ITexture* texture,
const irr::core::rect<irr::s32>& destRect,

View File

@ -579,6 +579,8 @@ void RaceGUI::drawGlobalMiniMap()
if (ctf_world)
{
Vec3 draw_at;
video::SColor translucence((unsigned)-1);
translucence.setAlpha(128);
if (!ctf_world->isRedFlagInBase())
{
track->mapPoint2MiniMap(Track::getCurrentTrack()->getRedFlag().getOrigin(),
@ -588,7 +590,7 @@ void RaceGUI::drawGlobalMiniMap()
lower_y -(int)(draw_at.getY()+(m_minimap_player_size/2.2f)),
m_map_left+(int)(draw_at.getX()+(m_minimap_player_size/1.4f)),
lower_y -(int)(draw_at.getY()-(m_minimap_player_size/2.2f)));
draw2DImage(m_red_flag, rp, rs, NULL, NULL, true, true);
draw2DImage(m_red_flag, rp, rs, NULL, translucence, true);
}
Vec3 pos = ctf_world->getRedHolder() == -1 ? ctf_world->getRedFlag() :
ctf_world->getKart(ctf_world->getRedHolder())->getSmoothedTrans().getOrigin();
@ -610,7 +612,7 @@ void RaceGUI::drawGlobalMiniMap()
lower_y -(int)(draw_at.getY()+(m_minimap_player_size/2.2f)),
m_map_left+(int)(draw_at.getX()+(m_minimap_player_size/1.4f)),
lower_y -(int)(draw_at.getY()-(m_minimap_player_size/2.2f)));
draw2DImage(m_blue_flag, rp, rs, NULL, NULL, true, true);
draw2DImage(m_blue_flag, rp, rs, NULL, translucence, true);
}
pos = ctf_world->getBlueHolder() == -1 ? ctf_world->getBlueFlag() :

View File

@ -1129,7 +1129,12 @@ void RaceGUIBase::drawPlayerIcon(AbstractKart *kart, int x, int y, int w,
{
const core::rect<s32> rect(core::position2d<s32>(0,0),
icon->getSize());
draw2DImage(icon, pos, rect, NULL, NULL, true, kart->isGhostKart());
video::SColor translucence((unsigned)-1);
translucence.setAlpha(128);
if (kart->isGhostKart())
draw2DImage(icon, pos, rect, NULL, translucence, true);
else
draw2DImage(icon, pos, rect, NULL, NULL, true);
}
//draw status info - icon fade out in case of rescue/explode