Update benches to latest glium display setup api
[mandelwow.git] / benches / bounding_box.rs
1 #![feature(test)]
2
3 extern crate mandelwow_lib;
4 extern crate glutin;
5 #[macro_use(uniform)]
6 extern crate glium;
7 extern crate test;
8
9 use mandelwow_lib::Cube;
10 use mandelwow_lib::bounding_box::*;
11
12 #[bench]
13 fn bench_bounding_box(b: &mut test::Bencher) {
14     let events_loop = glium::glutin::EventsLoop::new();
15     let window = glium::glutin::WindowBuilder::new();
16     let context = glium::glutin::ContextBuilder::new();
17     let display = glium::Display::new(window, context, &events_loop).unwrap();
18
19     let program = solid_fill_program(&display);
20     let bounds = Cube { xmin: -2., xmax: 0.7, ymin: -1., ymax:  1., zmin: -1.1, zmax:  1.1 };
21     let bbox = BoundingBox::new(&display, &bounds, &program);
22     let mut frame = display.draw();
23     b.iter(|| {
24         let mat = [[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.0f32]];
25         let uniforms = uniform! {
26             model: mat,
27             view: mat,
28             perspective: mat,
29         };
30         bbox.draw(&mut frame, &uniforms);
31     });
32     frame.finish().unwrap();
33 }