mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
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:
@@ -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"] }
|
||||
|
||||
Reference in New Issue
Block a user