From 83b949b1adcf71a564a34d26803716134727ac0c Mon Sep 17 00:00:00 2001 From: Joonas Javanainen Date: Sat, 26 Mar 2016 18:44:06 +0200 Subject: [PATCH] Hoist uniforms out of the draw list loop --- src/glium_renderer.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/glium_renderer.rs b/src/glium_renderer.rs index b37a0db..ed33407 100644 --- a/src/glium_renderer.rs +++ b/src/glium_renderer.rs @@ -88,19 +88,19 @@ impl Renderer { try!(self.device_objects.upload_index_buffer(&self.ctx, draw_list.idx_buffer)); let (width, height) = surface.get_dimensions(); + let matrix = [ + [ 2.0 / (width as f32), 0.0, 0.0, 0.0 ], + [ 0.0, 2.0 / -(height as f32), 0.0, 0.0 ], + [ 0.0, 0.0, -1.0, 0.0 ], + [ -1.0, 1.0, 0.0, 1.0 ] + ]; + let uniforms = uniform! { + matrix: matrix, + tex: &self.device_objects.texture + }; let mut idx_start = 0; for cmd in draw_list.cmd_buffer { - let matrix = [ - [ 2.0 / (width as f32), 0.0, 0.0, 0.0 ], - [ 0.0, 2.0 / -(height as f32), 0.0, 0.0 ], - [ 0.0, 0.0, -1.0, 0.0 ], - [ -1.0, 1.0, 0.0, 1.0 ] - ]; - let uniforms = uniform! { - matrix: matrix, - tex: &self.device_objects.texture - }; let draw_params = DrawParameters { blend: Blend::alpha_blending(), scissor: Some(Rect {