From ce6a82e7db7447e90650df00ccd185e9b258f1ae Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Mon, 9 Oct 2023 19:02:02 -0400 Subject: text: Draw with wish; stops the blinking bug. (because now, the text draws every frame, instead of just when it happens to change.) --- virtual-programs/display/text.folk | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'virtual-programs') diff --git a/virtual-programs/display/text.folk b/virtual-programs/display/text.folk index 1c8f6c45..992e77b1 100644 --- a/virtual-programs/display/text.folk +++ b/virtual-programs/display/text.folk @@ -38,7 +38,8 @@ On process "display" { set median [Gpu::fn {float r float g float b} float { return max(min(r, g), min(max(r, g), b)); }] - set glyph [Gpu::pipeline \ + # TODO: Do this with a wish, instead of hard-coding the global dict. + dict set ::pipelines "glyph" [Gpu::pipeline \ {sampler2D atlas vec2 atlasSize vec4 atlasGlyphBounds vec4 planeGlyphBounds @@ -74,7 +75,7 @@ On process "display" { float screenPxDistance = 4.5*(sd - 0.5); float opacity = clamp(screenPxDistance + 0.5, 0.0, 1.0); return mix(vec4(0, 0, 0, 0), vec4(1, 1, 1, 1), opacity); - }] + }] fn textExtent {text scale} { set em [* $scale 25.0] @@ -139,8 +140,8 @@ On process "display" { } lassign $glyphInfo advance planeBounds atlasBounds if {$char ne " "} { - lappend ::displayList \ - [list Gpu::draw $glyph $fontAtlas $fontAtlasSize \ + Wish the GPU draws pipeline "glyph" with arguments \ + [list $fontAtlas $fontAtlasSize \ $atlasBounds $planeBounds [list $x $y] $radians $em] } lassign [vec2 add [list $x $y] \ -- cgit v1.2.3