egui core library
To quickly get started with egui, you can take a look at egui_template
which uses eframe
.
To create a GUI using egui you first need a [CtxRef
] (by convention referred to by ctx
).
Use one of [SidePanel
], [TopPanel
], [CentralPanel
], [Window
] or [Area
] to
get access to an [Ui
] where you can put widgets. For example:
# let mut ctx = egui::CtxRef::default();
# ctx.begin_frame(Default::default());
egui::CentralPanel::default().show(&ctx, |ui| {
ui.label("Hello");
});
To write your own integration for egui you need to do this:
let mut egui_ctx = egui::CtxRef::default();
// Game loop:
loop {
let raw_input: egui::RawInput = my_integration.gather_input();
egui_ctx.begin_frame(raw_input);
my_app.ui(&egui_ctx); // add panels, windows and widgets to `egui_ctx` here
let (output, shapes) = egui_ctx.end_frame();
let paint_jobs = egui_ctx.tessellate(shapes); // create triangles to paint
my_integration.paint(paint_jobs);
my_integration.set_cursor_icon(output.cursor_icon);
// Also see `egui::Output` for more
}