mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Re-implement PaintCallbacks With Support for WGPU (#1684)
* Re-implement PaintCallbacks With Support for WGPU This makes breaking changes to the PaintCallback system, but makes it flexible enough to support both the WGPU and glow backends with custom rendering. Also adds a WGPU equivalent to the glow demo for custom painting.
This commit is contained in:
@@ -76,13 +76,9 @@ impl MyApp {
|
||||
|
||||
let callback = egui::PaintCallback {
|
||||
rect,
|
||||
callback: std::sync::Arc::new(move |_info, render_ctx| {
|
||||
if let Some(painter) = render_ctx.downcast_ref::<egui_glow::Painter>() {
|
||||
rotating_triangle.lock().paint(painter.gl(), angle);
|
||||
} else {
|
||||
eprintln!("Can't do custom painting because we are not using a glow context");
|
||||
}
|
||||
}),
|
||||
callback: std::sync::Arc::new(egui_glow::CallbackFn::new(move |_info, painter| {
|
||||
rotating_triangle.lock().paint(painter.gl(), angle);
|
||||
})),
|
||||
};
|
||||
ui.painter().add(callback);
|
||||
}
|
||||
|
||||
@@ -60,15 +60,11 @@ impl MyApp {
|
||||
|
||||
let callback = egui::PaintCallback {
|
||||
rect,
|
||||
callback: std::sync::Arc::new(move |info, render_ctx| {
|
||||
if let Some(painter) = render_ctx.downcast_ref::<egui_glow::Painter>() {
|
||||
with_three_d_context(painter.gl(), |three_d| {
|
||||
paint_with_three_d(three_d, info, angle);
|
||||
});
|
||||
} else {
|
||||
eprintln!("Can't do custom painting because we are not using a glow context");
|
||||
}
|
||||
}),
|
||||
callback: std::sync::Arc::new(egui_glow::CallbackFn::new(move |info, painter| {
|
||||
with_three_d_context(painter.gl(), |three_d| {
|
||||
paint_with_three_d(three_d, &info, angle);
|
||||
});
|
||||
})),
|
||||
};
|
||||
ui.painter().add(callback);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user