53 lines
1.2 KiB
Rust
53 lines
1.2 KiB
Rust
|
extern crate glium;
|
||
|
|
||
|
use glium::Display;
|
||
|
use glium::glutin;
|
||
|
use glium::glutin::{
|
||
|
EventsLoop,
|
||
|
WindowBuilder,
|
||
|
ContextBuilder,
|
||
|
};
|
||
|
|
||
|
use glium::glutin::Event;
|
||
|
use glium::glutin::WindowEvent;
|
||
|
use glium::glutin::VirtualKeyCode;
|
||
|
|
||
|
fn main() {
|
||
|
|
||
|
let mut events_loop = EventsLoop::new();
|
||
|
let window = WindowBuilder::new();
|
||
|
let context = ContextBuilder::new();
|
||
|
let display = Display::new(window, context, &events_loop).unwrap();
|
||
|
|
||
|
let mut closed = false;
|
||
|
|
||
|
while !closed {
|
||
|
let mut target = display.draw();
|
||
|
|
||
|
use glium::Surface;
|
||
|
target.clear_color(0.0, 0.0, 1.0, 1.0);
|
||
|
|
||
|
target.finish().unwrap();
|
||
|
|
||
|
events_loop.poll_events(|ev| {
|
||
|
match ev {
|
||
|
// Close window
|
||
|
Event::WindowEvent {
|
||
|
event: WindowEvent::Closed, ..
|
||
|
} => closed = true,
|
||
|
|
||
|
// Escape key
|
||
|
Event::WindowEvent {
|
||
|
event: WindowEvent::KeyboardInput {
|
||
|
input: glutin::KeyboardInput {
|
||
|
virtual_keycode: Some(VirtualKeyCode::Escape), ..
|
||
|
}, ..
|
||
|
}, ..
|
||
|
} => closed = true,
|
||
|
|
||
|
_ => (),
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|