Re-organize into module structure

This commit is contained in:
Osspial
2018-08-22 23:01:36 -04:00
parent f20fac99f6
commit 4377680a44
31 changed files with 740 additions and 701 deletions

View File

@@ -1,33 +1,36 @@
extern crate winit;
use std::collections::HashMap;
use winit::window::Window;
use winit::event::{Event, WindowEvent, ElementState, KeyboardInput};
use winit::event_loop::{EventLoop, ControlFlow};
fn main() {
let events_loop = winit::EventLoop::new();
let events_loop = EventLoop::new();
let mut windows = HashMap::new();
for _ in 0..3 {
let window = winit::Window::new(&events_loop).unwrap();
let window = Window::new(&events_loop).unwrap();
windows.insert(window.id(), window);
}
events_loop.run(move |event, events_loop, control_flow| {
*control_flow = winit::ControlFlow::Wait;
*control_flow = ControlFlow::Wait;
match event {
winit::Event::WindowEvent { event, window_id } => {
Event::WindowEvent { event, window_id } => {
match event {
winit::WindowEvent::CloseRequested => {
WindowEvent::CloseRequested => {
println!("Window {:?} has received the signal to close", window_id);
// This drops the window, causing it to close.
windows.remove(&window_id);
if windows.is_empty() {
*control_flow = winit::ControlFlow::Exit;
*control_flow = ControlFlow::Exit;
}
},
winit::WindowEvent::KeyboardInput{..} => {
let window = winit::Window::new(&events_loop).unwrap();
WindowEvent::KeyboardInput { input: KeyboardInput { state: ElementState::Pressed, .. }, .. } => {
let window = Window::new(&events_loop).unwrap();
windows.insert(window.id(), window);
},
_ => ()