From f944b517fa8bea6eae62eb25fbabe1308d16ed55 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Sat, 4 Jun 2016 10:54:33 -0700 Subject: Add live-reload for shaders Recompiling the entire program whenever a shader changes is slow, and it can interrupt flow. Shader reloads are essentially instantaneous now. If the new shader fails to compile, no state is changed; the previous program continues to be used. --- src/main.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index b6a36330..e5f9e0b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,7 @@ extern crate libc; extern crate glutin; extern crate cgmath; extern crate euclid; +extern crate notify; #[macro_use] mod macros; @@ -61,6 +62,7 @@ struct TermProps { cell_height: f32, sep_y: f32, height: f32, + width: f32, } fn main() { @@ -178,17 +180,18 @@ fn main() { gl::Clear(gl::COLOR_BUFFER_BIT); } + let props = TermProps { + cell_width: cell_width as f32, + sep_x: sep_x as f32, + cell_height: cell_height as f32, + sep_y: sep_y as f32, + height: height as f32, + width: width as f32, + }; + { let _sampler = meter.sampler(); - let props = TermProps { - cell_width: cell_width as f32, - sep_x: sep_x as f32, - cell_height: cell_height as f32, - sep_y: sep_y as f32, - height: height as f32, - }; - // Draw the grid renderer.render_grid(terminal.grid(), &glyph_cache, &props); @@ -199,7 +202,7 @@ fn main() { // Draw render timer let timing = format!("{:.3} usec", meter.average()); let color = Rgb { r: 0xd5, g: 0x4e, b: 0x53 }; - renderer.render_string(&timing[..], &glyph_cache, cell_width, &color); + renderer.render_string(&timing[..], &glyph_cache, &props, &color); window.swap_buffers().unwrap(); } -- cgit