Tidy up surface creation in RenderPlugin (#6276)
# Objective Tidy up a bit
This commit is contained in:
parent
708535536b
commit
b840ba3eaf
@ -146,20 +146,15 @@ impl Plugin for RenderPlugin {
|
|||||||
if let Some(backends) = options.backends {
|
if let Some(backends) = options.backends {
|
||||||
let windows = app.world.resource_mut::<bevy_window::Windows>();
|
let windows = app.world.resource_mut::<bevy_window::Windows>();
|
||||||
let instance = wgpu::Instance::new(backends);
|
let instance = wgpu::Instance::new(backends);
|
||||||
let surface = {
|
|
||||||
if let Some(window) = windows.get_primary() {
|
let surface = windows
|
||||||
if let Some(raw_window_handle) = window.raw_window_handle() {
|
.get_primary()
|
||||||
unsafe {
|
.and_then(|window| window.raw_window_handle())
|
||||||
let handle = raw_window_handle.get_handle();
|
.map(|wrapper| unsafe {
|
||||||
Some(instance.create_surface(&handle))
|
let handle = wrapper.get_handle();
|
||||||
}
|
instance.create_surface(&handle)
|
||||||
} else {
|
});
|
||||||
None
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let request_adapter_options = wgpu::RequestAdapterOptions {
|
let request_adapter_options = wgpu::RequestAdapterOptions {
|
||||||
power_preference: options.power_preference,
|
power_preference: options.power_preference,
|
||||||
compatible_surface: surface.as_ref(),
|
compatible_surface: surface.as_ref(),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user