mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 08:41:34 +11:00
Add a commit method for text_render
This commit is contained in:
parent
5701667f53
commit
dc4ccee451
|
@ -42,6 +42,8 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
writeln!(&mut writer, "Hello, World!").unwrap();
|
writeln!(&mut writer, "Hello, World!").unwrap();
|
||||||
writeln!(&mut writer, "This is a font rendering example").unwrap();
|
writeln!(&mut writer, "This is a font rendering example").unwrap();
|
||||||
|
|
||||||
|
writer.commit();
|
||||||
|
|
||||||
bg.commit();
|
bg.commit();
|
||||||
bg.show();
|
bg.show();
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,14 @@ impl<'a> Write for TextRenderer<'a> {
|
||||||
self.current_x_pos += letter.advance_width as i32;
|
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() {
|
for ((x, y), tile) in tiles.into_iter() {
|
||||||
self.bg.set_tile(
|
self.bg.set_tile(
|
||||||
self.vram_manager,
|
self.vram_manager,
|
||||||
|
@ -151,7 +159,5 @@ impl<'a> Write for TextRenderer<'a> {
|
||||||
);
|
);
|
||||||
self.vram_manager.remove_dynamic_tile(tile);
|
self.vram_manager.remove_dynamic_tile(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue