Sun, 19 Nov 2023 13:22:43 +0100
fix text rendering for alpha==0
src/ascension/text.h | file | annotate | diff | comparison | revisions | |
src/text.c | file | annotate | diff | comparison | revisions |
1.1 --- a/src/ascension/text.h Wed Nov 15 22:51:40 2023 +0100 1.2 +++ b/src/ascension/text.h Sun Nov 19 13:22:43 2023 +0100 1.3 @@ -36,6 +36,7 @@ 1.4 asc_vec2i position; 1.5 asc_vec2i dimension; 1.6 unsigned tex_id; 1.7 + bool hidden; 1.8 } AscTextNode; 1.9 1.10
2.1 --- a/src/text.c Wed Nov 15 22:51:40 2023 +0100 2.2 +++ b/src/text.c Sun Nov 19 13:22:43 2023 +0100 2.3 @@ -38,6 +38,12 @@ 2.4 unsigned max_width, 2.5 cxmutstr text) { 2.6 2.7 + // short circuit - if fully transparent, just hide it 2.8 + if (asc_context.ink.alpha == 0) { 2.9 + node->hidden = true; 2.10 + return; 2.11 + } 2.12 + 2.13 // Generate new texture, if required 2.14 if (node->tex_id == 0) { 2.15 glGenTextures(1, &node->tex_id); 2.16 @@ -93,6 +99,8 @@ 2.17 } 2.18 2.19 void asc_text_redraw(AscTextNode *node) { 2.20 + if (node->hidden) return; 2.21 + 2.22 if (node->tex_id == 0) { 2.23 asc_error("Tried to redraw text node after destruction"); 2.24 return;