Skip to content

Commit 2738fd9

Browse files
committed
fixed wasm executor
1 parent 93ce570 commit 2738fd9

File tree

2 files changed

+332
-346
lines changed

2 files changed

+332
-346
lines changed
Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,25 @@
11
//! Executor with your game connected to it as a plugin.
22
use fyrox::core::wasm_bindgen::{self, prelude::*};
3+
use fyrox::dpi::LogicalSize;
34
use fyrox::engine::executor::Executor;
5+
use fyrox::engine::GraphicsContextParams;
6+
use fyrox::event_loop::EventLoop;
7+
use fyrox::window::WindowAttributes;
48
use rpg::Game;
59

6-
#[wasm_bindgen]
7-
extern "C" {
8-
#[wasm_bindgen(js_namespace = console)]
9-
fn error(msg: String);
10-
11-
type Error;
12-
13-
#[wasm_bindgen(constructor)]
14-
fn new() -> Error;
15-
16-
#[wasm_bindgen(structural, method, getter)]
17-
fn stack(error: &Error) -> String;
18-
}
19-
20-
fn custom_panic_hook(info: &std::panic::PanicInfo) {
21-
let mut msg = info.to_string();
22-
msg.push_str("\n\nStack:\n\n");
23-
let e = Error::new();
24-
let stack = e.stack();
25-
msg.push_str(&stack);
26-
msg.push_str("\n\n");
27-
error(msg);
28-
}
29-
30-
#[inline]
31-
pub fn set_panic_hook() {
32-
use std::sync::Once;
33-
static SET_HOOK: Once = Once::new();
34-
SET_HOOK.call_once(|| {
35-
std::panic::set_hook(Box::new(custom_panic_hook));
36-
});
37-
}
38-
3910
#[wasm_bindgen]
4011
pub fn main() {
41-
set_panic_hook();
42-
let mut executor = Executor::new();
12+
let mut executor = Executor::from_params(
13+
EventLoop::new().ok(),
14+
GraphicsContextParams {
15+
window_attributes: WindowAttributes::default()
16+
.with_inner_size(LogicalSize::new(800, 600)),
17+
vsync: false,
18+
msaa_sample_count: None,
19+
graphics_server_constructor: Default::default(),
20+
named_objects: false,
21+
},
22+
);
4323
executor.add_plugin(Game::default());
4424
executor.run()
4525
}

0 commit comments

Comments
 (0)