Skip to content

Commit b840ba3

Browse files
committed
Tidy up surface creation in RenderPlugin (#6276)
# Objective Tidy up a bit
1 parent 7085355 commit b840ba3

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

crates/bevy_render/src/lib.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,15 @@ impl Plugin for RenderPlugin {
146146
if let Some(backends) = options.backends {
147147
let windows = app.world.resource_mut::<bevy_window::Windows>();
148148
let instance = wgpu::Instance::new(backends);
149-
let surface = {
150-
if let Some(window) = windows.get_primary() {
151-
if let Some(raw_window_handle) = window.raw_window_handle() {
152-
unsafe {
153-
let handle = raw_window_handle.get_handle();
154-
Some(instance.create_surface(&handle))
155-
}
156-
} else {
157-
None
158-
}
159-
} else {
160-
None
161-
}
162-
};
149+
150+
let surface = windows
151+
.get_primary()
152+
.and_then(|window| window.raw_window_handle())
153+
.map(|wrapper| unsafe {
154+
let handle = wrapper.get_handle();
155+
instance.create_surface(&handle)
156+
});
157+
163158
let request_adapter_options = wgpu::RequestAdapterOptions {
164159
power_preference: options.power_preference,
165160
compatible_surface: surface.as_ref(),

0 commit comments

Comments
 (0)