|
1 | 1 | //! Executor with your game connected to it as a plugin. |
2 | 2 | use fyrox::core::wasm_bindgen::{self, prelude::*}; |
| 3 | +use fyrox::dpi::LogicalSize; |
3 | 4 | use fyrox::engine::executor::Executor; |
| 5 | +use fyrox::engine::GraphicsContextParams; |
| 6 | +use fyrox::event_loop::EventLoop; |
| 7 | +use fyrox::window::WindowAttributes; |
4 | 8 | use rpg::Game; |
5 | 9 |
|
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 | | - |
39 | 10 | #[wasm_bindgen] |
40 | 11 | 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 | + ); |
43 | 23 | executor.add_plugin(Game::default()); |
44 | 24 | executor.run() |
45 | 25 | } |
0 commit comments