1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

egui_glium: allow sharing a native glium texture using Rc

This commit is contained in:
Emil Ernerfeldt
2021-09-20 22:52:29 +02:00
parent cfb6b31914
commit cf17cb2065
2 changed files with 19 additions and 22 deletions

View File

@@ -47,9 +47,11 @@ fn main() {
let image = load_glium_image(png_data);
let image_size = egui::Vec2::new(image.width as f32, image.height as f32);
// Load to gpu memory
let native_texture = glium::texture::SrgbTexture2d::new(&display, image).unwrap();
let glium_texture = glium::texture::SrgbTexture2d::new(&display, image).unwrap();
// Allow us to share the texture with egui:
let glium_texture = std::rc::Rc::new(glium_texture);
// Allocate egui's texture id for GL texture
let texture_id = egui.painter_mut().register_native_texture(native_texture);
let texture_id = egui.painter_mut().register_native_texture(glium_texture);
event_loop.run(move |event, _, control_flow| {
let mut redraw = || {