fix text rendering for alpha==0

Sun, 19 Nov 2023 13:22:43 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 19 Nov 2023 13:22:43 +0100
changeset 17
25013a35e07d
parent 16
c5dde81b6fb2
child 18
00c0632f0f40

fix text rendering for alpha==0

src/ascension/text.h file | annotate | diff | comparison | revisions
src/text.c file | annotate | diff | comparison | revisions
--- a/src/ascension/text.h	Wed Nov 15 22:51:40 2023 +0100
+++ b/src/ascension/text.h	Sun Nov 19 13:22:43 2023 +0100
@@ -36,6 +36,7 @@
     asc_vec2i position;
     asc_vec2i dimension;
     unsigned tex_id;
+    bool hidden;
 } AscTextNode;
 
 
--- a/src/text.c	Wed Nov 15 22:51:40 2023 +0100
+++ b/src/text.c	Sun Nov 19 13:22:43 2023 +0100
@@ -38,6 +38,12 @@
         unsigned max_width,
         cxmutstr text) {
 
+    // short circuit - if fully transparent, just hide it
+    if (asc_context.ink.alpha == 0) {
+        node->hidden = true;
+        return;
+    }
+
     // Generate new texture, if required
     if (node->tex_id == 0) {
         glGenTextures(1, &node->tex_id);
@@ -93,6 +99,8 @@
 }
 
 void asc_text_redraw(AscTextNode *node) {
+    if (node->hidden) return;
+
     if (node->tex_id == 0) {
         asc_error("Tried to redraw text node after destruction");
         return;

mercurial