fnl: eliminate text halo

Fill fully-transparent pixels on the destination texture with the text
color before rendering to it. This eliminates halos around text caused
by the invisible texture color (usually black) being blended with the
text.
This commit is contained in:
Nunuhara Cabbage
2022-04-30 10:52:55 -07:00
parent 0d771384da
commit a25f066a05
+13 -2
View File
@@ -790,11 +790,22 @@ void gfx_copy_stretch_with_alpha_map(Texture *dst, int dx, int dy, int dw, int d
// XXX: Not an actual DrawGraph function; used for rendering text
void gfx_draw_glyph(Texture *dst, float dx, int dy, Texture *glyph, SDL_Color color, float scale_x, float bold_width)
{
dx = roundf(dx);
glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ZERO, GL_ONE);
struct copy_data fill_data = COPY_DATA(dx, dy, dx, dy, glyph->w * scale_x, glyph->h);
fill_data.r = color.r / 255.0;
fill_data.g = color.g / 255.0;
fill_data.b = color.b / 255.0;
fill_data.a = 0.0;
fill_data.threshold = 0.001;
run_copy_shader(&fill_amap_under_border_shader.s, dst, dst, &fill_data);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
struct copy_data data = STRETCH_DATA(
roundf(dx), dy, glyph->w * scale_x, glyph->h,
0, 0, glyph->w, glyph->h);
dx, dy, glyph->w * scale_x, glyph->h,
0, 0, glyph->w, glyph->h);
data.r = color.r / 255.0;
data.g = color.g / 255.0;
data.b = color.b / 255.0;