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