-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Texture loading in egui #1110
Texture loading in egui #1110
Conversation
Hello I can not get eframe example (image.rs) to compile, there is no egui::ColorImage found and a few other errors. Also, image:: did not compile so I included image crate (0.24.0) in my Cargo.toml, I dont know if this is correct. Sorry, I am totally new to egui/eframe/epi and the examples in eframe are just fragments of code, not complete cargo projects.
thank for for any assistance |
I struggled with this too, in my case I managed to make it work using |
Soon 0.17.0 is released and this will become a lot simpler by using |
TextureId::Epaint was renamed to TextureId::Managed during the development of emilk#1110. Update the documentation to match. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
TextureId::Epaint was renamed to TextureId::Managed during the development of #1110. Update the documentation to match. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This continues #999 by moving texture allocation from
epi
intoegui
proper.With this PR you can convert an image into a texture using
egui::Context::load_texture
. This returns anegui::TextureHandle
which can be used with e.g.ui.image(…)
. TheTextureHandle
uses ref-counting, and when the lastTextureHandle
is dropped, the texture is freed. This makes it far more ergonomic and convenient to show images inegui
.Here is an example of how to use it: https://github.com/emilk/egui/blob/master/eframe/examples/image.rs
Backend integrations need to adapt by handling the new
epaint::TexturesDelta
each frame, a struct that specifies what textures were loaded and freed each frame.