Skip to content

Instantly share code, notes, and snippets.

@saik0
Last active January 25, 2017 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saik0/4d0ceb2e338d2c6249016adb962b4ff0 to your computer and use it in GitHub Desktop.
Save saik0/4d0ceb2e338d2c6249016adb962b4ff0 to your computer and use it in GitHub Desktop.
fn on_render(&mut self, window: &mut PistonWindow, ren: RenderArgs, e: Event) {
let fps = self.fps_counter.tick();
let ref front = self.front;
window.draw_2d(&e, |c, g| {
let rect = Rectangle::new(color::BLACK);
clear(color::WHITE, g);
let mut i = 0;
let mut bounds = [0.0, 0.0, SIZE, SIZE];
for y in 0..self.height {
for x in 0..self.width {
if front.get(i).unwrap() {
bounds[0] = x as f64 * SIZE;
bounds[1] = y as f64 * SIZE;
rect.draw(bounds, &c.draw_state, c.transform, g);
}
i += 1;
}
}
// disabled to bench rect drawing
//GRID.draw(&LINE, &c.draw_state, c.transform, g)
});
println!("fps: {}", fps);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment