From aa9d0de965a3c394963de26e642d81a14dcd2368 Mon Sep 17 00:00:00 2001 From: Chaojimengnan Date: Fri, 8 Mar 2024 19:43:07 +0800 Subject: [PATCH 1/2] Add `get_proc_address` in CreationContext --- crates/eframe/src/epi.rs | 4 ++++ crates/eframe/src/native/glow_integration.rs | 2 ++ crates/eframe/src/native/wgpu_integration.rs | 2 ++ 3 files changed, 8 insertions(+) diff --git a/crates/eframe/src/epi.rs b/crates/eframe/src/epi.rs index e26bece3a8d..ca239d6527c 100644 --- a/crates/eframe/src/epi.rs +++ b/crates/eframe/src/epi.rs @@ -67,6 +67,10 @@ pub struct CreationContext<'s> { #[cfg(feature = "glow")] pub gl: Option>, + /// The `get_proc_address` wrapper of underlying GL context + #[cfg(feature = "glow")] + pub get_proc_address: Option<&'s dyn Fn(&std::ffi::CStr) -> *const std::ffi::c_void>, + /// The underlying WGPU render state. /// /// Only available when compiling with the `wgpu` feature and using [`Renderer::Wgpu`]. diff --git a/crates/eframe/src/native/glow_integration.rs b/crates/eframe/src/native/glow_integration.rs index 0cb7ec331f9..8b1f16ec807 100644 --- a/crates/eframe/src/native/glow_integration.rs +++ b/crates/eframe/src/native/glow_integration.rs @@ -284,12 +284,14 @@ impl GlowWinitApp { // Use latest raw_window_handle for eframe compatibility use raw_window_handle::{HasDisplayHandle as _, HasWindowHandle as _}; + let get_proc_address = |addr: &_| glutin.get_proc_address(addr); let window = glutin.window(ViewportId::ROOT); let cc = CreationContext { egui_ctx: integration.egui_ctx.clone(), integration_info: integration.frame.info().clone(), storage: integration.frame.storage(), gl: Some(gl), + get_proc_address: Some(&get_proc_address), #[cfg(feature = "wgpu")] wgpu_render_state: None, raw_display_handle: window.display_handle().map(|h| h.as_raw()), diff --git a/crates/eframe/src/native/wgpu_integration.rs b/crates/eframe/src/native/wgpu_integration.rs index b3451be9cb0..61bf157c007 100644 --- a/crates/eframe/src/native/wgpu_integration.rs +++ b/crates/eframe/src/native/wgpu_integration.rs @@ -262,6 +262,8 @@ impl WgpuWinitApp { storage: integration.frame.storage(), #[cfg(feature = "glow")] gl: None, + #[cfg(feature = "glow")] + get_proc_address: None, wgpu_render_state, raw_display_handle: window.display_handle().map(|h| h.as_raw()), raw_window_handle: window.window_handle().map(|h| h.as_raw()), From f4d4a395ebbd215cf7bfb6fe06c292a201148e79 Mon Sep 17 00:00:00 2001 From: Chaojimengnan Date: Wed, 13 Mar 2024 00:29:14 +0800 Subject: [PATCH 2/2] Fix web build --- crates/eframe/src/web/app_runner.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/eframe/src/web/app_runner.rs b/crates/eframe/src/web/app_runner.rs index 6cb331dfba9..d63469110c7 100644 --- a/crates/eframe/src/web/app_runner.rs +++ b/crates/eframe/src/web/app_runner.rs @@ -76,6 +76,9 @@ impl AppRunner { #[cfg(feature = "glow")] gl: Some(painter.gl().clone()), + #[cfg(feature = "glow")] + get_proc_address: None, + #[cfg(all(feature = "wgpu", not(feature = "glow")))] wgpu_render_state: painter.render_state(), #[cfg(all(feature = "wgpu", feature = "glow"))]