2016-02-23 12:56:23 +01:00
|
|
|
extern crate winit;
|
2019-06-03 22:51:01 -07:00
|
|
|
#[cfg(feature = "stdweb")]
|
2019-03-09 21:54:29 -05:00
|
|
|
#[macro_use]
|
|
|
|
extern crate stdweb;
|
2019-06-03 22:51:01 -07:00
|
|
|
#[cfg(feature = "wasm-bindgen")]
|
2019-06-04 23:08:09 -07:00
|
|
|
extern crate wasm_bindgen;
|
2019-06-05 22:58:11 -07:00
|
|
|
#[cfg(feature = "wasm-bindgen")]
|
|
|
|
extern crate web_sys;
|
2019-03-09 21:54:29 -05:00
|
|
|
|
2019-02-05 10:30:33 -05:00
|
|
|
use winit::window::WindowBuilder;
|
|
|
|
use winit::event::{Event, WindowEvent};
|
|
|
|
use winit::event_loop::{EventLoop, ControlFlow};
|
2019-06-05 22:58:11 -07:00
|
|
|
use wasm_bindgen::{prelude::*, JsValue};
|
|
|
|
use web_sys::console;
|
2014-07-27 10:55:37 +02:00
|
|
|
|
2019-06-05 22:58:11 -07:00
|
|
|
#[wasm_bindgen(start)]
|
|
|
|
pub fn main() {
|
|
|
|
console::log_1(&JsValue::from_str("main"));
|
2019-02-05 10:30:33 -05:00
|
|
|
let event_loop = EventLoop::new();
|
2017-01-28 15:01:59 +01:00
|
|
|
|
2019-02-05 10:30:33 -05:00
|
|
|
let _window = WindowBuilder::new()
|
2016-11-11 22:08:46 +11:00
|
|
|
.with_title("A fantastic window!")
|
2019-02-05 10:30:33 -05:00
|
|
|
.build(&event_loop)
|
2016-11-11 22:08:46 +11:00
|
|
|
.unwrap();
|
2019-06-05 22:58:11 -07:00
|
|
|
console::log_1(&JsValue::from_str("Created window"));
|
2014-07-27 10:55:37 +02:00
|
|
|
|
2019-02-05 10:30:33 -05:00
|
|
|
event_loop.run(|event, _, control_flow| {
|
2019-06-05 22:58:11 -07:00
|
|
|
console::log_1(&JsValue::from_str(&format!("{:?}", event)));
|
2015-06-16 13:48:08 +02:00
|
|
|
|
|
|
|
match event {
|
2019-02-05 10:30:33 -05:00
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::CloseRequested,
|
2018-04-24 16:20:40 -04:00
|
|
|
..
|
2019-02-05 10:30:33 -05:00
|
|
|
} => *control_flow = ControlFlow::Exit,
|
2019-06-23 14:38:16 -07:00
|
|
|
_ => ()
|
2015-06-16 13:48:08 +02:00
|
|
|
}
|
2017-01-28 15:01:59 +01:00
|
|
|
});
|
2019-06-05 22:58:11 -07:00
|
|
|
}
|