mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
Fix that transparent text still draws a text shadow (#13649)
Makes fade out animations of text more pleasant to look at.
This commit is contained in:
parent
f41e9e3e0f
commit
3552537fc4
@ -678,13 +678,6 @@ void CGUITTFont::draw(const EnrichedString &text, const core::rect<s32>& positio
|
||||
CGUITTGlyphPage* page = it->second;
|
||||
++it;
|
||||
|
||||
if (shadow_offset) {
|
||||
for (size_t i = 0; i < page->render_positions.size(); ++i)
|
||||
page->render_positions[i] += core::vector2di(shadow_offset, shadow_offset);
|
||||
Driver->draw2DImageBatch(page->texture, page->render_positions, page->render_source_rects, clip, video::SColor(shadow_alpha,0,0,0), true);
|
||||
for (size_t i = 0; i < page->render_positions.size(); ++i)
|
||||
page->render_positions[i] -= core::vector2di(shadow_offset, shadow_offset);
|
||||
}
|
||||
// render runs of matching color in batch
|
||||
size_t ibegin;
|
||||
video::SColor colprev;
|
||||
@ -700,6 +693,19 @@ void CGUITTFont::draw(const EnrichedString &text, const core::rect<s32>& positio
|
||||
|
||||
if (!use_transparency)
|
||||
colprev.color |= 0xff000000;
|
||||
|
||||
if (shadow_offset) {
|
||||
for (size_t i = 0; i < tmp_positions.size(); ++i)
|
||||
tmp_positions[i] += core::vector2di(shadow_offset, shadow_offset);
|
||||
|
||||
u32 new_shadow_alpha = core::clamp(core::round32(shadow_alpha * colprev.getAlpha() / 255.0f), 0, 255);
|
||||
video::SColor shadow_color = video::SColor(new_shadow_alpha, 0, 0, 0);
|
||||
Driver->draw2DImageBatch(page->texture, tmp_positions, tmp_source_rects, clip, shadow_color, true);
|
||||
|
||||
for (size_t i = 0; i < tmp_positions.size(); ++i)
|
||||
tmp_positions[i] -= core::vector2di(shadow_offset, shadow_offset);
|
||||
}
|
||||
|
||||
Driver->draw2DImageBatch(page->texture, tmp_positions, tmp_source_rects, clip, colprev, true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user