mirror of
https://github.com/emilk/egui.git
synced 2026-07-17 03:58:53 +00: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:
@@ -188,6 +188,7 @@ impl EpiIntegration {
|
||||
window: &winit::window::Window,
|
||||
storage: Option<Box<dyn epi::Storage>>,
|
||||
#[cfg(feature = "glow")] gl: Option<std::sync::Arc<glow::Context>>,
|
||||
#[cfg(feature = "wgpu")] render_state: Option<egui_wgpu::RenderState>,
|
||||
) -> Self {
|
||||
let egui_ctx = egui::Context::default();
|
||||
|
||||
@@ -207,6 +208,8 @@ impl EpiIntegration {
|
||||
storage,
|
||||
#[cfg(feature = "glow")]
|
||||
gl,
|
||||
#[cfg(feature = "wgpu")]
|
||||
render_state,
|
||||
};
|
||||
|
||||
if prefer_dark_mode == Some(true) {
|
||||
|
||||
@@ -62,6 +62,8 @@ pub fn run_glow(
|
||||
gl_window.window(),
|
||||
storage,
|
||||
Some(gl.clone()),
|
||||
#[cfg(feature = "wgpu")]
|
||||
None,
|
||||
);
|
||||
|
||||
{
|
||||
@@ -76,6 +78,8 @@ pub fn run_glow(
|
||||
integration_info: integration.frame.info(),
|
||||
storage: integration.frame.storage(),
|
||||
gl: Some(gl.clone()),
|
||||
#[cfg(feature = "wgpu")]
|
||||
render_state: None,
|
||||
});
|
||||
|
||||
if app.warm_up_enabled() {
|
||||
@@ -230,6 +234,8 @@ pub fn run_wgpu(
|
||||
painter
|
||||
};
|
||||
|
||||
let render_state = painter.get_render_state().expect("Uninitialized");
|
||||
|
||||
let mut integration = epi_integration::EpiIntegration::new(
|
||||
&event_loop,
|
||||
painter.max_texture_side().unwrap_or(2048),
|
||||
@@ -237,6 +243,7 @@ pub fn run_wgpu(
|
||||
storage,
|
||||
#[cfg(feature = "glow")]
|
||||
None,
|
||||
Some(render_state.clone()),
|
||||
);
|
||||
|
||||
{
|
||||
@@ -252,6 +259,7 @@ pub fn run_wgpu(
|
||||
storage: integration.frame.storage(),
|
||||
#[cfg(feature = "glow")]
|
||||
gl: None,
|
||||
render_state: Some(render_state),
|
||||
});
|
||||
|
||||
if app.warm_up_enabled() {
|
||||
|
||||
Reference in New Issue
Block a user