rust/hwrunner/src/main.rs
changeset 14192 675aa499a70e
child 14193 3b83ec44e10b
equal deleted inserted replaced
14191:0d18ecb520ed 14192:675aa499a70e
       
     1 use glutin::{
       
     2     dpi::LogicalSize,
       
     3     Event,
       
     4     WindowEvent,
       
     5     EventsLoop,
       
     6     GlWindow,
       
     7 };
       
     8 
       
     9 fn init(event_loop: &EventsLoop, size: LogicalSize) -> GlWindow {
       
    10     use glutin::{
       
    11         ContextBuilder,
       
    12         WindowBuilder
       
    13     };
       
    14 
       
    15     let window = WindowBuilder::new()
       
    16         .with_title("hwengine")
       
    17         .with_dimensions(size);
       
    18 
       
    19     let context = ContextBuilder::new();
       
    20     GlWindow::new(window, context, event_loop).unwrap()
       
    21 }
       
    22 
       
    23 fn main() {
       
    24     let mut event_loop = EventsLoop::new();
       
    25     let window = init(&event_loop, LogicalSize::new(1024.0, 768.0));
       
    26 
       
    27     let mut is_running = true;
       
    28     while is_running {
       
    29         event_loop.poll_events(|event| {
       
    30             match event {
       
    31                 Event::WindowEvent { event, ..} => match event {
       
    32                     WindowEvent::CloseRequested => {
       
    33                         is_running = false;
       
    34                     },
       
    35                     _ => ()
       
    36                 },
       
    37                 _ => ()
       
    38             }
       
    39         })
       
    40     }
       
    41 }