Created
August 15, 2015 17:53
-
-
Save LLBlumire/b343135eab6c07cb6696 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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