rust/hwrunner/src/main.rs
changeset 15788 19ad3fe48ea6
parent 14737 8e74d4eb89f5
child 15798 ec85fdf82942
equal deleted inserted replaced
15787:713f89f6c6ab 15788:19ad3fe48ea6
    48 
    48 
    49     use std::time::Instant;
    49     use std::time::Instant;
    50 
    50 
    51     let mut now = Instant::now();
    51     let mut now = Instant::now();
    52     let mut update = Instant::now();
    52     let mut update = Instant::now();
       
    53     let mut render = Instant::now();
    53 
    54 
       
    55     unsafe { window.make_current().unwrap() };
    54     let mut is_running = true;
    56     let mut is_running = true;
       
    57 
    55     while is_running {
    58     while is_running {
    56         let curr = Instant::now();
    59         let curr = Instant::now();
    57         let delta = curr - now;
    60         let delta = curr - now;
    58         now = curr;
    61         now = curr;
    59         let ms = delta.as_secs() as f64 * 1000.0 + delta.subsec_millis() as f64;
    62         let ms = delta.as_secs() as f64 * 1000.0 + delta.subsec_millis() as f64;
    98                 _ => {}
   101                 _ => {}
    99             },
   102             },
   100             _ => (),
   103             _ => (),
   101         });
   104         });
   102 
   105 
   103         unsafe { window.make_current().unwrap() };
   106         if render.elapsed() > Duration::from_millis(16) {
   104 
   107             render = curr;
   105         engine.render();
   108             engine.render();
   106         window.swap_buffers().unwrap();
   109             window.swap_buffers().unwrap();
       
   110         }
   107     }
   111     }
   108 }
   112 }