Fix benchmarks for latest glium/glutin API
[mandelwow.git] / support / mod.rs
index 8996e55de71827c6e2f93b8a2153c42ba7832d34..562b1b535ca07d4a297f40d916dbbcda8b961421 100644 (file)
@@ -1,13 +1,5 @@
 #![allow(dead_code)]
 
-extern crate genmesh;
-extern crate obj;
-
-use std::thread;
-use std::time::{Duration, Instant};
-use glium::{self, Display};
-use glium::vertex::VertexBufferAny;
-
 pub mod camera;
 pub mod vec3;
 
@@ -17,69 +9,10 @@ pub enum Action {
 }
 
 pub fn start_loop<F>(mut callback: F) where F: FnMut() -> Action {
-    let mut accumulator = Duration::new(0, 0);
-    let mut previous_clock = Instant::now();
-
     loop {
         match callback() {
             Action::Stop => break,
             Action::Continue => ()
         };
-
-        let now = Instant::now();
-        accumulator += now - previous_clock;
-        previous_clock = now;
-
-        let fixed_time_stamp = Duration::new(0, 16666667);
-        while accumulator >= fixed_time_stamp {
-            accumulator -= fixed_time_stamp;
-
-            // if you have a game, update the state here
-        }
-
-        thread::sleep(fixed_time_stamp - accumulator);
-    }
-}
-
-/// Returns a vertex buffer that should be rendered as `TrianglesList`.
-pub fn load_wavefront(display: &Display, data: &[u8]) -> VertexBufferAny {
-    #[derive(Copy, Clone)]
-    struct Vertex {
-        position: [f32; 3],
-        normal: [f32; 3],
-        texture: [f32; 2],
     }
-
-    implement_vertex!(Vertex, position, normal, texture);
-
-    let mut data = ::std::io::BufReader::new(data);
-    let data = obj::Obj::load(&mut data);
-
-    let mut vertex_data = Vec::new();
-
-    for object in data.object_iter() {
-        for shape in object.group_iter().flat_map(|g| g.indices().iter()) {
-            match shape {
-                &genmesh::Polygon::PolyTri(genmesh::Triangle { x: v1, y: v2, z: v3 }) => {
-                    for v in [v1, v2, v3].iter() {
-                        let position = data.position()[v.0];
-                        let texture = v.1.map(|index| data.texture()[index]);
-                        let normal = v.2.map(|index| data.normal()[index]);
-
-                        let texture = texture.unwrap_or([0.0, 0.0]);
-                        let normal = normal.unwrap_or([0.0, 0.0, 0.0]);
-
-                        vertex_data.push(Vertex {
-                            position: position,
-                            normal: normal,
-                            texture: texture,
-                        })
-                    }
-                },
-                _ => unimplemented!()
-            }
-        }
-    }
-
-    glium::vertex::VertexBuffer::new(display, &vertex_data).unwrap().into_vertex_buffer_any()
 }