From dc4ccee4510fa5c264429cbc8782927bd67d279c Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Thu, 7 Apr 2022 23:01:01 +0100 Subject: [PATCH] Add a commit method for text_render --- agb/examples/text_render.rs | 2 ++ agb/src/display/font.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/agb/examples/text_render.rs b/agb/examples/text_render.rs index 39b9049b..f465a67a 100644 --- a/agb/examples/text_render.rs +++ b/agb/examples/text_render.rs @@ -42,6 +42,8 @@ fn main(mut gba: agb::Gba) -> ! { writeln!(&mut writer, "Hello, World!").unwrap(); writeln!(&mut writer, "This is a font rendering example").unwrap(); + writer.commit(); + bg.commit(); bg.show(); diff --git a/agb/src/display/font.rs b/agb/src/display/font.rs index ed41cdbb..70b8a136 100644 --- a/agb/src/display/font.rs +++ b/agb/src/display/font.rs @@ -142,6 +142,14 @@ impl<'a> Write for TextRenderer<'a> { self.current_x_pos += letter.advance_width as i32; } + Ok(()) + } +} + +impl<'a> TextRenderer<'a> { + pub fn commit(mut self) { + let tiles = core::mem::take(&mut self.tiles); + for ((x, y), tile) in tiles.into_iter() { self.bg.set_tile( self.vram_manager, @@ -151,7 +159,5 @@ impl<'a> Write for TextRenderer<'a> { ); self.vram_manager.remove_dynamic_tile(tile); } - - Ok(()) } }