1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

Add egui_wgpu crate (#1564)

Based on https://github.com/hasenbanck/egui_wgpu_backend

`egui-wgpu` is now an official backend for `eframe` (opt-in).

Use the `wgpu` feature flag on `eframe` and the `NativeOptions::renderer` settings to pick it.

Co-authored-by: Nils Hasenbanck <nils@hasenbanck.de>
Co-authored-by: Sven Niederberger <niederberger@embotech.com>
Co-authored-by: Sven Niederberger <73159570+s-nie@users.noreply.github.com>
This commit is contained in:
Emil Ernerfeldt
2022-05-12 09:02:28 +02:00
committed by GitHub
parent 3d52cc8867
commit 931e716b97
32 changed files with 1540 additions and 101 deletions

View File

@@ -9,6 +9,6 @@ publish = false
[dependencies]
eframe = { path = "../../eframe" }
eframe = { path = "../../eframe", features = ["glow"] }
egui_glow = { path = "../../egui_glow" }
glow = "0.11"

View File

@@ -10,6 +10,7 @@ fn main() {
let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(350.0, 380.0)),
multisampling: 8,
renderer: eframe::Renderer::Glow,
..Default::default()
};
eframe::run_native(
@@ -27,8 +28,12 @@ struct MyApp {
impl MyApp {
fn new(cc: &eframe::CreationContext<'_>) -> Self {
let gl = cc
.gl
.as_ref()
.expect("You need to run eframe with the glow backend");
Self {
rotating_triangle: Arc::new(Mutex::new(RotatingTriangle::new(&cc.gl))),
rotating_triangle: Arc::new(Mutex::new(RotatingTriangle::new(gl))),
angle: 0.0,
}
}
@@ -51,8 +56,10 @@ impl eframe::App for MyApp {
});
}
fn on_exit(&mut self, gl: &glow::Context) {
self.rotating_triangle.lock().destroy(gl);
fn on_exit(&mut self, gl: Option<&glow::Context>) {
if let Some(gl) = gl {
self.rotating_triangle.lock().destroy(gl);
}
}
}

View File

@@ -9,7 +9,7 @@ publish = false
[dependencies]
eframe = { path = "../../eframe" }
eframe = { path = "../../eframe", features = ["glow"] }
egui_glow = { path = "../../egui_glow" }
glow = "0.11"
three-d = { version = "0.11", default-features = false }

View File

@@ -6,6 +6,7 @@ fn main() {
let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(550.0, 610.0)),
multisampling: 8,
renderer: eframe::Renderer::Glow,
..Default::default()
};
eframe::run_native(