X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=support%2Fmod.rs;h=b71f50d7c50a2f84c18b4bfb2702771087623f82;hb=23b897973be569e94d2c7c9696123ff72c34890f;hp=068a524b4817dd5ce4c10a28579473029c8f3cc4;hpb=95d84a2a2ba1ddd546671f60424345f1ba9948a3;p=mandelwow.git diff --git a/support/mod.rs b/support/mod.rs index 068a524..b71f50d 100644 --- a/support/mod.rs +++ b/support/mod.rs @@ -3,12 +3,11 @@ 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; pub enum Action { Stop, @@ -16,27 +15,11 @@ pub enum Action { } pub fn start_loop(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); } }