mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 05:10:03 -04:00
[wgpu] Expose wgpu::Adapter via RenderState (#2954)
* [wgpu] Expose adapter, better errors, better docs, more code sharing, use stencil bits * doc fix * remove unnecessary unsafe * handle missing framebuffer format * better handling of renderstate creation in winit.rs * remove unnecessary use directive
This commit is contained in:
@@ -1122,9 +1122,7 @@ mod wgpu_integration {
|
||||
) -> std::result::Result<(), egui_wgpu::WgpuError> {
|
||||
self.window = Some(window);
|
||||
if let Some(running) = &mut self.running {
|
||||
unsafe {
|
||||
pollster::block_on(running.painter.set_window(self.window.as_ref()))?;
|
||||
}
|
||||
pollster::block_on(running.painter.set_window(self.window.as_ref()))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -1134,9 +1132,7 @@ mod wgpu_integration {
|
||||
fn drop_window(&mut self) -> std::result::Result<(), egui_wgpu::WgpuError> {
|
||||
self.window = None;
|
||||
if let Some(running) = &mut self.running {
|
||||
unsafe {
|
||||
pollster::block_on(running.painter.set_window(None))?;
|
||||
}
|
||||
pollster::block_on(running.painter.set_window(None))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -1148,16 +1144,16 @@ mod wgpu_integration {
|
||||
window: winit::window::Window,
|
||||
) -> std::result::Result<(), egui_wgpu::WgpuError> {
|
||||
#[allow(unsafe_code, unused_mut, unused_unsafe)]
|
||||
let painter = unsafe {
|
||||
let mut painter = egui_wgpu::winit::Painter::new(
|
||||
self.native_options.wgpu_options.clone(),
|
||||
self.native_options.multisampling.max(1) as _,
|
||||
let mut painter = egui_wgpu::winit::Painter::new(
|
||||
self.native_options.wgpu_options.clone(),
|
||||
self.native_options.multisampling.max(1) as _,
|
||||
egui_wgpu::depth_format_from_bits(
|
||||
self.native_options.depth_buffer,
|
||||
self.native_options.transparent,
|
||||
);
|
||||
pollster::block_on(painter.set_window(Some(&window)))?;
|
||||
painter
|
||||
};
|
||||
self.native_options.stencil_buffer,
|
||||
),
|
||||
self.native_options.transparent,
|
||||
);
|
||||
pollster::block_on(painter.set_window(Some(&window)))?;
|
||||
|
||||
let wgpu_render_state = painter.render_state();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user