From b977a151874fb97742e61b60cba494766a4ec697 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Mon, 6 Jun 2016 13:29:05 -0700 Subject: Batching flushes on texture change This fixes a bug when multiple atlases are required. --- src/renderer/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index ff2963f7..379e22ee 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -184,7 +184,7 @@ impl Batch { /// Maximum items to be drawn in a batch. const BATCH_MAX: usize = 4096; -const ATLAS_SIZE: i32 = 512; +const ATLAS_SIZE: i32 = 1024; impl QuadRenderer { // TODO should probably hand this a transform instead of width/height @@ -481,6 +481,13 @@ impl<'a> RenderApi<'a> { #[inline] fn add_render_item(&mut self, row: f32, col: f32, color: Rgb, glyph: &Glyph) { + // Flush batch if tex changing + if !self.batch.is_empty() { + if self.batch.tex != glyph.tex_id { + self.render_batch(); + } + } + self.batch.add_item(row, col, color, glyph); // Render batch and clear if it's full -- cgit v1.2.3-54-g00ecf