Skip to content

Instantly share code, notes, and snippets.

@LLBlumire
Created August 15, 2015 17:53
Show Gist options
  • Save LLBlumire/b343135eab6c07cb6696 to your computer and use it in GitHub Desktop.
Save LLBlumire/b343135eab6c07cb6696 to your computer and use it in GitHub Desktop.
loop {
let init_time = PreciseTime::now();
/* Draw and Event Loop */
let term_time = PreciseTime::now();
let duration = init_time.to(term_time);
let desired_duration = Duration::milliseconds((1000.0/60.0) as i64);
let offset = desired_duration.num_milliseconds() - duration.num_milliseconds();
if duration < desired_duration {
thread::sleep_ms(offset as u32);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment