mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
@@ -439,7 +439,7 @@ pub struct WebOptions {
|
||||
/// Unused by webgl context as of writing.
|
||||
pub depth_buffer: u8,
|
||||
|
||||
/// Which version of WebGl context to select
|
||||
/// Which version of WebGL context to select
|
||||
///
|
||||
/// Default: [`WebGlContextOption::BestFirst`].
|
||||
#[cfg(feature = "glow")]
|
||||
|
||||
@@ -14,7 +14,7 @@ impl EventLoopGuard {
|
||||
cell.get().is_none(),
|
||||
"Attempted to set a new event loop while one is already set"
|
||||
);
|
||||
cell.set(Some(event_loop as *const ActiveEventLoop));
|
||||
cell.set(Some(std::ptr::from_ref::<ActiveEventLoop>(event_loop)));
|
||||
});
|
||||
Self
|
||||
}
|
||||
|
||||
@@ -1,42 +1,14 @@
|
||||
use raw_window_handle::{
|
||||
DisplayHandle, HandleError, HasDisplayHandle, HasWindowHandle, RawDisplayHandle,
|
||||
RawWindowHandle, WebDisplayHandle, WebWindowHandle, WindowHandle,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
use wasm_bindgen::JsValue;
|
||||
use web_sys::HtmlCanvasElement;
|
||||
|
||||
use crate::WebOptions;
|
||||
use egui_wgpu::{RenderState, SurfaceErrorAction, WgpuSetup};
|
||||
|
||||
use crate::WebOptions;
|
||||
|
||||
use super::web_painter::WebPainter;
|
||||
|
||||
struct EguiWebWindow(u32);
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl HasWindowHandle for EguiWebWindow {
|
||||
fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError> {
|
||||
// SAFETY: there is no lifetime here.
|
||||
unsafe {
|
||||
Ok(WindowHandle::borrow_raw(RawWindowHandle::Web(
|
||||
WebWindowHandle::new(self.0),
|
||||
)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl HasDisplayHandle for EguiWebWindow {
|
||||
fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError> {
|
||||
// SAFETY: there is no lifetime here.
|
||||
unsafe {
|
||||
Ok(DisplayHandle::borrow_raw(RawDisplayHandle::Web(
|
||||
WebDisplayHandle::new(),
|
||||
)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct WebPainterWgpu {
|
||||
canvas: HtmlCanvasElement,
|
||||
surface: wgpu::Surface<'static>,
|
||||
|
||||
@@ -16,7 +16,7 @@ pub struct WebRunner {
|
||||
/// Have we ever panicked?
|
||||
panic_handler: PanicHandler,
|
||||
|
||||
/// If we ever panic during running, this RefCell is poisoned.
|
||||
/// If we ever panic during running, this `RefCell` is poisoned.
|
||||
/// So before we use it, we need to check [`Self::panic_handler`].
|
||||
runner: Rc<RefCell<Option<AppRunner>>>,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user