1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00

Use canvas directly (#4780)

This commit is contained in:
Jan Procházka
2024-07-15 18:59:15 +02:00
committed by GitHub
parent cb9f30482f
commit 0d89e31e3e
10 changed files with 22 additions and 27 deletions

View File

@@ -83,7 +83,10 @@ impl WebPainterWgpu {
}
#[allow(unused)] // only used if `wgpu` is the only active feature.
pub async fn new(canvas_id: &str, options: &WebOptions) -> Result<Self, String> {
pub async fn new(
canvas: web_sys::HtmlCanvasElement,
options: &WebOptions,
) -> Result<Self, String> {
log::debug!("Creating wgpu painter");
let mut backends = options.wgpu_options.supported_backends;
@@ -162,7 +165,6 @@ impl WebPainterWgpu {
}
}
let canvas = super::get_canvas_element_by_id_or_die(canvas_id);
let surface = instance
.create_surface(wgpu::SurfaceTarget::Canvas(canvas.clone()))
.map_err(|err| format!("failed to create wgpu surface: {err}"))?;