Minor wgpu-web releated stuff (#1977)
* egui_demo_app: remove wgpu and pollster as direct dependencies * eframe: use same web-sys version as wgpu crate * Make note that web_sys_unstable_apis is required by the wgpu crate * Rename the glow web painter in eframe * Remove trait DummyWebGLConstructor from web_glow_painter.rs * cargo fmt * Fix check.sh
This commit is contained in:
parent
dbfaa4527b
commit
3142c52b94
8 changed files with 23 additions and 27 deletions
3
.github/workflows/rust.yml
vendored
3
.github/workflows/rust.yml
vendored
|
@ -3,7 +3,8 @@ on: [push, pull_request]
|
|||
name: CI
|
||||
|
||||
env:
|
||||
# web_sys_unstable_apis is required to enable the web_sys clipboard API which eframe web uses
|
||||
# web_sys_unstable_apis is required to enable the web_sys clipboard API which eframe web uses,
|
||||
# as well as by the wasm32-backend of the wgpu crate.
|
||||
# https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html
|
||||
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
|
||||
RUSTFLAGS: --cfg=web_sys_unstable_apis -D warnings
|
||||
|
|
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -1257,12 +1257,10 @@ dependencies = [
|
|||
"ehttp",
|
||||
"image",
|
||||
"poll-promise",
|
||||
"pollster",
|
||||
"serde",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"tracing-wasm",
|
||||
"wgpu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4260,9 +4258,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.59"
|
||||
version = "0.3.58"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1"
|
||||
checksum = "2fed94beee57daf8dd7d51f2b15dc2bcde92d7a72304cdf662a4371008b71b90"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
|
|
|
@ -99,7 +99,7 @@ js-sys = "0.3"
|
|||
percent-encoding = "2.1"
|
||||
wasm-bindgen = "0.2"
|
||||
wasm-bindgen-futures = "0.4"
|
||||
web-sys = { version = "0.3.52", features = [
|
||||
web-sys = { version = "0.3.58", features = [
|
||||
"BinaryType",
|
||||
"Blob",
|
||||
"Clipboard",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{glow_wrapping::WrappedGlowPainter, *};
|
||||
use super::{WebPainter, *};
|
||||
|
||||
use crate::epi;
|
||||
|
||||
|
@ -162,7 +162,7 @@ fn test_parse_query() {
|
|||
pub struct AppRunner {
|
||||
pub(crate) frame: epi::Frame,
|
||||
egui_ctx: egui::Context,
|
||||
painter: WrappedGlowPainter,
|
||||
painter: WebPainter,
|
||||
pub(crate) input: WebInput,
|
||||
app: Box<dyn epi::App>,
|
||||
pub(crate) needs_repaint: std::sync::Arc<NeedRepaint>,
|
||||
|
@ -187,8 +187,8 @@ impl AppRunner {
|
|||
web_options: crate::WebOptions,
|
||||
app_creator: epi::AppCreator,
|
||||
) -> Result<Self, JsValue> {
|
||||
let painter = WrappedGlowPainter::new(canvas_id, web_options.webgl_context_option)
|
||||
.map_err(JsValue::from)?; // fail early
|
||||
let painter =
|
||||
WebPainter::new(canvas_id, web_options.webgl_context_option).map_err(JsValue::from)?; // fail early
|
||||
|
||||
let system_theme = if web_options.follow_system_theme {
|
||||
super::system_theme()
|
||||
|
|
|
@ -4,15 +4,16 @@
|
|||
|
||||
pub mod backend;
|
||||
mod events;
|
||||
mod glow_wrapping;
|
||||
mod input;
|
||||
pub mod screen_reader;
|
||||
pub mod storage;
|
||||
mod text_agent;
|
||||
mod web_glow_painter;
|
||||
|
||||
pub use backend::*;
|
||||
pub use events::*;
|
||||
pub use storage::*;
|
||||
pub(crate) use web_glow_painter::WebPainter;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::{
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
use crate::WebGlContextOption;
|
||||
use egui::{ClippedPrimitive, Rgba};
|
||||
use egui_glow::glow;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::JsValue;
|
||||
use web_sys::HtmlCanvasElement;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use web_sys::{WebGl2RenderingContext, WebGlRenderingContext};
|
||||
|
||||
pub(crate) struct WrappedGlowPainter {
|
||||
use egui::{ClippedPrimitive, Rgba};
|
||||
use egui_glow::glow;
|
||||
|
||||
use crate::WebGlContextOption;
|
||||
|
||||
pub(crate) struct WebPainter {
|
||||
pub(crate) canvas: HtmlCanvasElement,
|
||||
pub(crate) canvas_id: String,
|
||||
pub(crate) painter: egui_glow::Painter,
|
||||
}
|
||||
|
||||
impl WrappedGlowPainter {
|
||||
impl WebPainter {
|
||||
pub fn new(canvas_id: &str, options: WebGlContextOption) -> Result<Self, String> {
|
||||
let canvas = super::canvas_element_or_die(canvas_id);
|
||||
|
||||
|
@ -32,7 +34,7 @@ impl WrappedGlowPainter {
|
|||
}
|
||||
}
|
||||
|
||||
impl WrappedGlowPainter {
|
||||
impl WebPainter {
|
||||
pub fn gl(&self) -> &std::sync::Arc<glow::Context> {
|
||||
self.painter.gl()
|
||||
}
|
||||
|
@ -158,9 +160,3 @@ fn init_webgl2(canvas: &HtmlCanvasElement) -> Option<(glow::Context, &'static st
|
|||
|
||||
Some((gl, shader_prefix))
|
||||
}
|
||||
|
||||
trait DummyWebGLConstructor {
|
||||
fn from_webgl1_context(context: web_sys::WebGlRenderingContext) -> Self;
|
||||
|
||||
fn from_webgl2_context(context: web_sys::WebGl2RenderingContext) -> Self;
|
||||
}
|
|
@ -34,7 +34,7 @@ serde = [
|
|||
syntax_highlighting = ["egui_demo_lib/syntax_highlighting"]
|
||||
|
||||
glow = ["eframe/glow"]
|
||||
wgpu = ["eframe/wgpu", "bytemuck", "pollster", "dep:wgpu"]
|
||||
wgpu = ["eframe/wgpu", "bytemuck"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
|
@ -48,7 +48,6 @@ tracing = "0.1"
|
|||
|
||||
bytemuck = { version = "1.7.1", optional = true }
|
||||
egui_extras = { version = "0.19.0", optional = true, path = "../egui_extras" }
|
||||
wgpu = { version = "0.13", optional = true, features = ["webgl"] }
|
||||
|
||||
# feature "http":
|
||||
ehttp = { version = "0.2.0", optional = true }
|
||||
|
@ -57,7 +56,6 @@ image = { version = "0.24", optional = true, default-features = false, features
|
|||
"png",
|
||||
] }
|
||||
poll-promise = { version = "0.1", optional = true, default-features = false }
|
||||
pollster = { version = "0.2.5", optional = true }
|
||||
|
||||
# feature "persistence":
|
||||
serde = { version = "1", optional = true, features = ["derive"] }
|
||||
|
|
|
@ -11,7 +11,9 @@ set -x
|
|||
|
||||
cargo install cargo-cranky # Uses lints defined in Cranky.toml. See https://github.com/ericseppanen/cargo-cranky
|
||||
|
||||
export RUSTFLAGS="-D warnings"
|
||||
# web_sys_unstable_apis is required to enable the web_sys clipboard API which eframe web uses,
|
||||
# as well as by the wasm32-backend of the wgpu crate.
|
||||
export RUSTFLAGS="--cfg=web_sys_unstable_apis -D warnings"
|
||||
export RUSTDOCFLAGS="-D warnings" # https://github.com/emilk/egui/pull/1454
|
||||
|
||||
cargo check --all-targets
|
||||
|
|
Loading…
Reference in a new issue