diff --git a/egui_glow/CHANGELOG.md b/egui_glow/CHANGELOG.md index 078145c4..260842dc 100644 --- a/egui_glow/CHANGELOG.md +++ b/egui_glow/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to the `egui_glow` integration will be noted in this file. * `EguiGlow::new` now takes an `EventLoopWindowTarget` instead of a `winit::Window` ([#1634](https://github.com/emilk/egui/pull/1634)). * Use `Arc` for `glow::Context` instead of `Rc` ([#1640](https://github.com/emilk/egui/pull/1640)). * Fixed `glClear` on WebGL1 ([#1658](https://github.com/emilk/egui/pull/1658)). +* Add `Painter::intermediate_fbo` which tells callbacks where to render. This is only needed if the callbacks use their own FBO:s and need to know what to restore to. ## 0.18.1 - 2022-05-05 diff --git a/egui_glow/src/painter.rs b/egui_glow/src/painter.rs index de2bfb20..0645b9a5 100644 --- a/egui_glow/src/painter.rs +++ b/egui_glow/src/painter.rs @@ -248,6 +248,19 @@ impl Painter { self.max_texture_side } + /// The framebuffer we use as an intermediate render target, + /// or `None` if we are painting to the screen framebuffer directly. + /// + /// This is the framebuffer that is bound when [`egui::Shape::Callback`] is called, + /// and is where any callbacks should ultimately render onto. + /// + /// So if in a [`egui::Shape::Callback`] you need to use an offscreen FBO, you should + /// then restore to this afterwards with + /// `gl.bind_framebuffer(glow::FRAMEBUFFER, painter.intermediate_fbo());` + pub fn intermediate_fbo(&self) -> Option { + self.post_process.as_ref().map(|pp| pp.fbo()) + } + unsafe fn prepare_painting( &mut self, [width_in_pixels, height_in_pixels]: [u32; 2], diff --git a/egui_glow/src/post_process.rs b/egui_glow/src/post_process.rs index 8d692eb4..a593d789 100644 --- a/egui_glow/src/post_process.rs +++ b/egui_glow/src/post_process.rs @@ -176,6 +176,11 @@ impl PostProcess { }) } + /// What we render to. + pub(crate) fn fbo(&self) -> glow::Framebuffer { + self.fbo + } + pub(crate) unsafe fn begin(&mut self, width: i32, height: i32) { if (width, height) != self.texture_size { self.gl