Function rerun::external::eframe::run_simple_native

pub fn run_simple_native(
    app_name: &str,
    native_options: NativeOptions,
    update_fun: impl FnMut(&Context, &mut Frame) + 'static
) -> Result<(), Error>
Expand description

The simplest way to get started when writing a native app.

This does NOT support persistence of custom user data. For that you need to use run_native. However, it DOES support persistence of egui data (window positions and sizes, how far the user has scrolled in a ScrollArea, etc.) if the persistence feature is enabled.

§Example

fn main() -> eframe::Result {
    // Our application state:
    let mut name = "Arthur".to_owned();
    let mut age = 42;

    let options = eframe::NativeOptions::default();
    eframe::run_simple_native("My egui App", options, move |ctx, _frame| {
        egui::CentralPanel::default().show(ctx, |ui| {
            ui.heading("My egui Application");
            ui.horizontal(|ui| {
                let name_label = ui.label("Your name: ");
                ui.text_edit_singleline(&mut name)
                    .labelled_by(name_label.id);
            });
            ui.add(egui::Slider::new(&mut age, 0..=120).text("age"));
            if ui.button("Increment").clicked() {
                age += 1;
            }
            ui.label(format!("Hello '{name}', age {age}"));
        });
    })
}

§Errors

This function can fail if we fail to set up a graphics context.