FyroxEngine / Fyrox

3D and 2D game engine written in Rust
https://fyrox.rs
MIT License
7.64k stars 343 forks source link

resize with WindowEvent::Resized #405

Closed GOVYANSONG closed 1 year ago

GOVYANSONG commented 1 year ago

I am trying to use set_frame_size() method as illustrated in various examples. but it is not available as public method. What is the correct way to respond to window resizing?

1

just saw the source code here: https://github.com/FyroxEngine/Fyrox/blob/23d81ed9690529c9bbab8ea7d99522163e0236a7/src/engine/executor.rs. If it is done internally, then there may be something else going on: the executor-wasm example, when i resized the browser window, the content did not scale/zoom according to new size.

so my question is how to scale the scene in relation to the surrounding window size. maybe related to this issue: https://github.com/FyroxEngine/Fyrox/pull/306

2

just checked the wasm example with animated mutant, if i modify the css for #main with a size, the rendered content will respect that setting.

3

more code here let window_builder = fyrox::window::WindowBuilder::new() .with_inner_size(LogicalSize::new(200, 200)) .with_title("Example - WASM") .with_resizable(true);

mrDIMAS commented 1 year ago

There're multiple ways to change size of the window (or canvas on wasm), one - is to use context.window.set_inner_size(..), second - specify the size in Executor - as it implements Deref<Target = Engine> you can do executor.get_window().set_inner_size(..). Hope that helps.