mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Simplify backends by adding fn paint_and_update_textures helper
This commit is contained in:
@@ -83,14 +83,9 @@ pub fn run(app: Box<dyn epi::App>, native_options: &epi::NativeOptions) -> ! {
|
||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
||||
}
|
||||
|
||||
let (needs_repaint, mut textures_delta, shapes) =
|
||||
integration.update(gl_window.window());
|
||||
let (needs_repaint, textures_delta, shapes) = integration.update(gl_window.window());
|
||||
let clipped_meshes = integration.egui_ctx.tessellate(shapes);
|
||||
|
||||
for (id, image_delta) in textures_delta.set {
|
||||
painter.set_texture(&gl, id, &image_delta);
|
||||
}
|
||||
|
||||
// paint:
|
||||
{
|
||||
let color = integration.app.clear_color();
|
||||
@@ -100,20 +95,17 @@ pub fn run(app: Box<dyn epi::App>, native_options: &epi::NativeOptions) -> ! {
|
||||
gl.clear_color(color[0], color[1], color[2], color[3]);
|
||||
gl.clear(glow::COLOR_BUFFER_BIT);
|
||||
}
|
||||
painter.paint_meshes(
|
||||
painter.paint_and_update_textures(
|
||||
&gl,
|
||||
gl_window.window().inner_size().into(),
|
||||
integration.egui_ctx.pixels_per_point(),
|
||||
clipped_meshes,
|
||||
&textures_delta,
|
||||
);
|
||||
|
||||
gl_window.swap_buffers().unwrap();
|
||||
}
|
||||
|
||||
for id in textures_delta.free.drain(..) {
|
||||
painter.free_texture(&gl, id);
|
||||
}
|
||||
|
||||
{
|
||||
*control_flow = if integration.should_quit() {
|
||||
winit::event_loop::ControlFlow::Exit
|
||||
|
||||
Reference in New Issue
Block a user