Skip to content

Commit

Permalink
egui_web: always use the glow painter, and remove the old WebGL code.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Mar 11, 2022
1 parent 510cef0 commit 88f0aef
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 1,481 deletions.
4 changes: 1 addition & 3 deletions eframe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ egui_glow = { version = "0.17.0", path = "../egui_glow", optional = true, defaul

# web:
[target.'cfg(target_arch = "wasm32")'.dependencies]
egui_web = { version = "0.17.0", path = "../egui_web", default-features = false, features = [
"glow",
] }
egui_web = { version = "0.17.0", path = "../egui_web", default-features = false }


[dev-dependencies]
Expand Down
17 changes: 2 additions & 15 deletions egui_web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,12 @@ crate-type = ["cdylib", "rlib"]


[features]
default = ["default_fonts", "glow"]
default = ["default_fonts"]

# If set, egui will use `include_bytes!` to bundle some fonts.
# If you plan on specifying your own fonts you may disable this feature.
default_fonts = ["egui/default_fonts"]

# Use glow as the renderer.
glow = ["egui_glow", "egui_glow/epi"]

# Alternative to the glow renderer.
webgl = []

# enable persisting egui memory
persistence = ["egui/persistence", "ron", "serde"]

Expand All @@ -52,7 +46,7 @@ egui = { version = "0.17.0", path = "../egui", default-features = false, feature
"single_threaded",
"tracing",
] }
egui_glow = { version = "0.17.0", path = "../egui_glow", optional = true, default-features = false }
egui_glow = { version = "0.17.0", path = "../egui_glow", default-features = false }
epi = { version = "0.17.0", path = "../epi" }

bytemuck = "1.7"
Expand Down Expand Up @@ -106,15 +100,8 @@ features = [
"TouchEvent",
"TouchList",
"WebGl2RenderingContext",
"WebGlBuffer",
"WebglDebugRendererInfo",
"WebGlFramebuffer",
"WebGlProgram",
"WebGlRenderingContext",
"WebGlShader",
"WebGlTexture",
"WebGlUniformLocation",
"WebGlVertexArrayObject",
"WheelEvent",
"Window",
]
2 changes: 1 addition & 1 deletion egui_web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Check out [eframe_template](https://github.com/emilk/eframe_template) for an exa

## Downsides with using egui on the web

`egui_web` uses WebGL and WASM, and almost nothing else from the web tech stack. This has some benefits, but also produces some challanges and serious downsides.
`egui_web` uses WebGL (via [`glow`](https://crates.io/crates/glow)) and WASM, and almost nothing else from the web tech stack. This has some benefits, but also produces some challanges and serious downsides.

* Rendering: Getting pixel-perfect rendering right on the web is very difficult.
* Search: you cannot search an egui web page like you would a normal web page.
Expand Down
19 changes: 2 additions & 17 deletions egui_web/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,9 @@ pub use egui::{pos2, Color32};
// ----------------------------------------------------------------------------

fn create_painter(canvas_id: &str) -> Result<Box<dyn Painter>, JsValue> {
// Glow takes precedence:
#[cfg(all(feature = "glow"))]
return Ok(Box::new(
Ok(Box::new(
crate::glow_wrapping::WrappedGlowPainter::new(canvas_id).map_err(JsValue::from)?,
));

#[cfg(all(feature = "webgl", not(feature = "glow")))]
if let Ok(webgl2_painter) = webgl2::WebGl2Painter::new(canvas_id) {
tracing::debug!("Using WebGL2 backend");
Ok(Box::new(webgl2_painter))
} else {
tracing::debug!("Falling back to WebGL1 backend");
let webgl1_painter = webgl1::WebGlPainter::new(canvas_id)?;
Ok(Box::new(webgl1_painter))
}

#[cfg(all(not(feature = "webgl"), not(feature = "glow")))]
compile_error!("Either the 'glow' or 'webgl' feature of egui_web must be enabled!");
))
}

// ----------------------------------------------------------------------------
Expand Down
6 changes: 0 additions & 6 deletions egui_web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@
#![warn(clippy::all, rustdoc::missing_crate_level_docs, rust_2018_idioms)]

pub mod backend;
#[cfg(feature = "glow")]
mod glow_wrapping;
mod input;
mod painter;
pub mod screen_reader;
mod text_agent;

#[cfg(feature = "webgl")]
pub mod webgl1;
#[cfg(feature = "webgl")]
pub mod webgl2;

pub use backend::*;

use egui::mutex::{Mutex, MutexGuard};
Expand Down
58 changes: 0 additions & 58 deletions egui_web/src/shader/fragment_100es.glsl

This file was deleted.

13 changes: 0 additions & 13 deletions egui_web/src/shader/main_fragment_100es.glsl

This file was deleted.

31 changes: 0 additions & 31 deletions egui_web/src/shader/main_vertex_100es.glsl

This file was deleted.

26 changes: 0 additions & 26 deletions egui_web/src/shader/post_fragment_100es.glsl

This file was deleted.

8 changes: 0 additions & 8 deletions egui_web/src/shader/post_vertex_100es.glsl

This file was deleted.

Loading

0 comments on commit 88f0aef

Please sign in to comment.