Skip to content
\n

The window only gets its values after the WindowEvent::Resized event.

\n
WindowEvent::Resized(physical_size) => state.resize(*physical_size),
\n

But I need the window size before the Resized event in order to configure the wgpu.

\n
let config = wgpu::SurfaceConfiguration {\n  usage: wgpu::TextureUsages::RENDER_ATTACHMENT,\n  format: surface_format,\n  width: size.width,\n  height: size.height,\n  present_mode: surface_caps.present_modes[0],\n  alpha_mode: surface_caps.alpha_modes[0],\n  view_formats: vec![]\n};
\n

Target: wasm32
\nwgpu = \"0.18.0\"
\nwinit = { version = \"0.29.4\", features = [\"rwh_05\"] }

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

See #2863.

\n

Unfortunately this is not possible, as we use ResizeObserver to figure out the size of the canvas, which is async by nature. This is unfortunately a limitation by the Web API.

","upvoteCount":1,"url":"https://github.com/rust-windowing/winit/discussions/3262#discussioncomment-7851509"}}}
Discussion options

You must be logged in to vote

See #2863.

Unfortunately this is not possible, as we use ResizeObserver to figure out the size of the canvas, which is async by nature. This is unfortunately a limitation by the Web API.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@devrangel
Comment options

@daxpedda
Comment options

Answer selected by devrangel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
DS - web Affects the Web backend (WebAssembly/WASM)
2 participants