1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 23:13:13 -04:00

eframe: rename render_state to wgpu_render_state for added clarity

This commit is contained in:
Emil Ernerfeldt
2022-08-08 12:15:31 +02:00
parent 66c601f775
commit 9e41fa021a
6 changed files with 37 additions and 23 deletions

View File

@@ -27,13 +27,18 @@ pub struct CreationContext<'s> {
/// The [`glow::Context`] allows you to initialize OpenGL resources (e.g. shaders) that
/// you might want to use later from a [`egui::PaintCallback`].
///
/// Only available when compiling with the `glow` feature and using [`Renderer::Glow`].
#[cfg(feature = "glow")]
pub gl: Option<std::sync::Arc<glow::Context>>,
/// Can be used to manage GPU resources for custom rendering with WGPU using
/// [`egui::PaintCallback`]s.
/// The underlying WGPU render state.
///
/// Only available when compiling with the `wgpu` feature and using [`Renderer::Wgpu`].
///
/// Can be used to manage GPU resources for custom rendering with WGPU using [`egui::PaintCallback`]s.
#[cfg(feature = "wgpu")]
pub render_state: Option<egui_wgpu::RenderState>,
pub wgpu_render_state: Option<egui_wgpu::RenderState>,
}
// ----------------------------------------------------------------------------
@@ -510,10 +515,9 @@ pub struct Frame {
#[cfg(feature = "glow")]
pub(crate) gl: Option<std::sync::Arc<glow::Context>>,
/// Can be used to manage GPU resources for custom rendering with WGPU using
/// [`egui::PaintCallback`]s.
/// Can be used to manage GPU resources for custom rendering with WGPU using [`egui::PaintCallback`]s.
#[cfg(feature = "wgpu")]
pub render_state: Option<egui_wgpu::RenderState>,
pub(crate) wgpu_render_state: Option<egui_wgpu::RenderState>,
}
impl Frame {
@@ -551,12 +555,22 @@ impl Frame {
/// ([`egui`] only collects [`egui::Shape`]s and then eframe paints them all in one go later on).
///
/// To get a [`glow`] context you need to compile with the `glow` feature flag,
/// and run eframe with the glow backend.
/// and run eframe using [`Renderer::Glow`].
#[cfg(feature = "glow")]
pub fn gl(&self) -> Option<&std::sync::Arc<glow::Context>> {
self.gl.as_ref()
}
/// The underlying WGPU render state.
///
/// Only available when compiling with the `wgpu` feature and using [`Renderer::Wgpu`].
///
/// Can be used to manage GPU resources for custom rendering with WGPU using [`egui::PaintCallback`]s.
#[cfg(feature = "wgpu")]
pub fn wgpu_render_state(&self) -> Option<&egui_wgpu::RenderState> {
self.wgpu_render_state.as_ref()
}
/// Signal the app to stop/exit/quit the app (only works for native apps, not web apps).
/// The framework will not quit immediately, but at the end of the this frame.
#[cfg(not(target_arch = "wasm32"))]

View File

@@ -196,7 +196,7 @@ impl EpiIntegration {
system_theme: Option<Theme>,
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>,
#[cfg(feature = "wgpu")] wgpu_render_state: Option<egui_wgpu::RenderState>,
) -> Self {
let egui_ctx = egui::Context::default();
@@ -214,7 +214,7 @@ impl EpiIntegration {
#[cfg(feature = "glow")]
gl,
#[cfg(feature = "wgpu")]
render_state,
wgpu_render_state,
};
let mut egui_winit = egui_winit::State::new(event_loop);

View File

@@ -254,7 +254,7 @@ mod glow_integration {
storage: integration.frame.storage(),
gl: Some(gl.clone()),
#[cfg(feature = "wgpu")]
render_state: None,
wgpu_render_state: None,
});
if app.warm_up_enabled() {
@@ -484,7 +484,7 @@ mod wgpu_integration {
painter
};
let render_state = painter.get_render_state().expect("Uninitialized");
let wgpu_render_state = painter.render_state().expect("Uninitialized");
let system_theme = native_options.system_theme();
let mut integration = epi_integration::EpiIntegration::new(
@@ -495,7 +495,7 @@ mod wgpu_integration {
storage,
#[cfg(feature = "glow")]
None,
Some(render_state.clone()),
Some(wgpu_render_state.clone()),
);
let theme = system_theme.unwrap_or(native_options.default_theme);
integration.egui_ctx.set_visuals(theme.egui_visuals());
@@ -513,7 +513,7 @@ mod wgpu_integration {
storage: integration.frame.storage(),
#[cfg(feature = "glow")]
gl: None,
render_state: Some(render_state),
wgpu_render_state: Some(wgpu_render_state),
});
if app.warm_up_enabled() {

View File

@@ -219,7 +219,7 @@ impl AppRunner {
#[cfg(feature = "glow")]
gl: Some(painter.painter.gl().clone()),
#[cfg(feature = "wgpu")]
render_state: None,
wgpu_render_state: None,
});
let frame = epi::Frame {
@@ -229,7 +229,7 @@ impl AppRunner {
#[cfg(feature = "glow")]
gl: Some(painter.gl().clone()),
#[cfg(feature = "wgpu")]
render_state: None,
wgpu_render_state: None,
};
let needs_repaint: std::sync::Arc<NeedRepaint> = Default::default();