mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
eframe: always provide a texture allocator
This commit is contained in:
@@ -45,7 +45,7 @@ impl epi::App for ColorTest {
|
||||
ui.separator();
|
||||
}
|
||||
ScrollArea::auto_sized().show(ui, |ui| {
|
||||
self.ui(ui, frame.tex_allocator());
|
||||
self.ui(ui, &mut Some(frame.tex_allocator()));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -278,14 +278,16 @@ impl TexMngr {
|
||||
url: &str,
|
||||
image: &Image,
|
||||
) -> Option<egui::TextureId> {
|
||||
let tex_allocator = frame.tex_allocator().as_mut()?;
|
||||
if self.loaded_url != url {
|
||||
if let Some(texture_id) = self.texture_id.take() {
|
||||
tex_allocator.free(texture_id);
|
||||
frame.tex_allocator().free(texture_id);
|
||||
}
|
||||
|
||||
self.texture_id =
|
||||
Some(tex_allocator.alloc_srgba_premultiplied(image.size, &image.pixels));
|
||||
self.texture_id = Some(
|
||||
frame
|
||||
.tex_allocator()
|
||||
.alloc_srgba_premultiplied(image.size, &image.pixels),
|
||||
);
|
||||
self.loaded_url = url.to_owned();
|
||||
}
|
||||
self.texture_id
|
||||
|
||||
Reference in New Issue
Block a user