Merge remote-tracking branch 'blm/web-sys' into stdweb-eventloop-2
This commit is contained in:
commit
eea9530f38
13 changed files with 1050 additions and 18 deletions
|
|
@ -1,22 +1,31 @@
|
|||
extern crate winit;
|
||||
#[cfg(feature = "stdweb")]
|
||||
#[macro_use]
|
||||
extern crate stdweb;
|
||||
#[cfg(feature = "wasm-bindgen")]
|
||||
extern crate wasm_bindgen;
|
||||
#[cfg(feature = "wasm-bindgen")]
|
||||
extern crate web_sys;
|
||||
|
||||
use winit::window::WindowBuilder;
|
||||
use winit::event::{Event, WindowEvent};
|
||||
use winit::event_loop::{EventLoop, ControlFlow};
|
||||
use wasm_bindgen::{prelude::*, JsValue};
|
||||
use web_sys::console;
|
||||
|
||||
fn main() {
|
||||
#[wasm_bindgen(start)]
|
||||
pub fn main() {
|
||||
console::log_1(&JsValue::from_str("main"));
|
||||
let event_loop = EventLoop::new();
|
||||
|
||||
let _window = WindowBuilder::new()
|
||||
.with_title("A fantastic window!")
|
||||
.build(&event_loop)
|
||||
.unwrap();
|
||||
console!(log, "Built window!");
|
||||
console::log_1(&JsValue::from_str("Created window"));
|
||||
|
||||
event_loop.run(|event, _, control_flow| {
|
||||
console!(log, format!("{:?}", event));
|
||||
console::log_1(&JsValue::from_str(&format!("{:?}", event)));
|
||||
|
||||
match event {
|
||||
Event::WindowEvent {
|
||||
|
|
@ -26,4 +35,4 @@ fn main() {
|
|||
_ => ()
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue