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