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:
Zicklag
2022-05-28 10:52:36 -05:00
committed by GitHub
parent 8173093c67
commit 1d9524cc59
22 changed files with 595 additions and 130 deletions
+3
View File
@@ -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) {
+8
View File
@@ -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() {