1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 22:00:03 -04:00

Make wgpu the default renderer for eframe and egui.rs (#7615)

* Closes https://github.com/emilk/egui/issues/5889

See the above issue for motivation.

To use glow instead, disable the default features of `eframe` and opt-in
to `glow`.

This also changes egui.rs to use wgpu, which means WebGPU when
available, and WebGL otherwise
This commit is contained in:
Emil Ernerfeldt
2025-11-13 11:16:23 +01:00
committed by GitHub
parent 51b0d0e4b9
commit 9ef610e16b
9 changed files with 90 additions and 43 deletions

View File

@@ -471,6 +471,10 @@ impl Default for NativeOptions {
/// Options when using `eframe` in a web page.
#[cfg(target_arch = "wasm32")]
pub struct WebOptions {
/// What rendering backend to use.
#[cfg(any(feature = "glow", feature = "wgpu_no_default_features"))]
pub renderer: Renderer,
/// Sets the number of bits in the depth buffer.
///
/// `egui` doesn't need the depth buffer, so the default value is 0.
@@ -519,6 +523,9 @@ pub struct WebOptions {
impl Default for WebOptions {
fn default() -> Self {
Self {
#[cfg(any(feature = "glow", feature = "wgpu_no_default_features"))]
renderer: Renderer::default(),
depth_buffer: 0,
#[cfg(feature = "glow")]
@@ -592,8 +599,8 @@ impl Default for Renderer {
#[cfg(feature = "wgpu_no_default_features")]
return Self::Wgpu;
// By default, only the `glow` feature is enabled, so if the user added `wgpu` to the feature list
// they probably wanted to use wgpu:
// It's weird that the user has enabled both glow and wgpu,
// but let's pick the better of the two (wgpu):
#[cfg(feature = "glow")]
#[cfg(feature = "wgpu_no_default_features")]
return Self::Wgpu;