Function eframe::run_native
source · [−]pub fn run_native(
app_name: &str,
native_options: NativeOptions,
app_creator: AppCreator
) -> !
Expand description
This is how you start a native (desktop) app.
The first argument is name of your app, used for the title bar of the native window
and the save location of persistence (see App::save
).
Call from fn main
like this:
use eframe::egui;
fn main() {
let native_options = eframe::NativeOptions::default();
eframe::run_native("MyApp", native_options, Box::new(|cc| Box::new(MyEguiApp::new(cc))));
}
#[derive(Default)]
struct MyEguiApp {}
impl MyEguiApp {
fn new(cc: &eframe::CreationContext<'_>) -> Self {
// Customize egui here with cc.egui_ctx.set_fonts and cc.egui_ctx.set_visuals.
// Restore app state using cc.storage (requires the "persistence" feature).
// Use the cc.gl (a glow::Context) to create graphics shaders and buffers that you can use
// for e.g. egui::PaintCallback.
Self::default()
}
}
impl eframe::App for MyEguiApp {
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("Hello World!");
});
}
}