Skip to content

Commit 8b992f4

Browse files
Chaojimengnanhacknus
authored andcommitted
Add get_proc_address in CreationContext (emilk#4145)
<!-- Please read the "Making a PR" section of [`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md) before opening a Pull Request! * Keep your PR:s small and focused. * The PR title is what ends up in the changelog, so make it descriptive! * If applicable, add a screenshot or gif. * If it is a non-trivial addition, consider adding a demo for it to `egui_demo_lib`, or a new example. * Do NOT open PR:s from your `master` branch, as that makes it hard for maintainers to add commits to your PR. * Remember to run `cargo fmt` and `cargo cranky`. * Open the PR as a draft until you have self-reviewed it and run `./scripts/check.sh`. * When you have addressed a PR comment, mark it as resolved. Please be patient! I will review your PR, but my time is limited! --> * Closes <emilk#4144>
1 parent 59934a2 commit 8b992f4

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

crates/eframe/src/epi.rs

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ pub struct CreationContext<'s> {
6767
#[cfg(feature = "glow")]
6868
pub gl: Option<std::sync::Arc<glow::Context>>,
6969

70+
/// The `get_proc_address` wrapper of underlying GL context
71+
#[cfg(feature = "glow")]
72+
pub get_proc_address: Option<&'s dyn Fn(&std::ffi::CStr) -> *const std::ffi::c_void>,
73+
7074
/// The underlying WGPU render state.
7175
///
7276
/// Only available when compiling with the `wgpu` feature and using [`Renderer::Wgpu`].

crates/eframe/src/native/glow_integration.rs

+2
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,14 @@ impl GlowWinitApp {
284284
// Use latest raw_window_handle for eframe compatibility
285285
use raw_window_handle::{HasDisplayHandle as _, HasWindowHandle as _};
286286

287+
let get_proc_address = |addr: &_| glutin.get_proc_address(addr);
287288
let window = glutin.window(ViewportId::ROOT);
288289
let cc = CreationContext {
289290
egui_ctx: integration.egui_ctx.clone(),
290291
integration_info: integration.frame.info().clone(),
291292
storage: integration.frame.storage(),
292293
gl: Some(gl),
294+
get_proc_address: Some(&get_proc_address),
293295
#[cfg(feature = "wgpu")]
294296
wgpu_render_state: None,
295297
raw_display_handle: window.display_handle().map(|h| h.as_raw()),

crates/eframe/src/native/wgpu_integration.rs

+2
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ impl WgpuWinitApp {
262262
storage: integration.frame.storage(),
263263
#[cfg(feature = "glow")]
264264
gl: None,
265+
#[cfg(feature = "glow")]
266+
get_proc_address: None,
265267
wgpu_render_state,
266268
raw_display_handle: window.display_handle().map(|h| h.as_raw()),
267269
raw_window_handle: window.window_handle().map(|h| h.as_raw()),

crates/eframe/src/web/app_runner.rs

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ impl AppRunner {
7676
#[cfg(feature = "glow")]
7777
gl: Some(painter.gl().clone()),
7878

79+
#[cfg(feature = "glow")]
80+
get_proc_address: None,
81+
7982
#[cfg(all(feature = "wgpu", not(feature = "glow")))]
8083
wgpu_render_state: painter.render_state(),
8184
#[cfg(all(feature = "wgpu", feature = "glow"))]

0 commit comments

Comments
 (0)