Expand description
§egui_speedy2d
egui_speedy2d is a library that helps integrate egui, an immediate mode GUI library, with speedy2d, a 2D rendering framework.
§Usage
The easiest way to use egui_speedy2d is to make your main WindowHandler struct
implement egui_speedy2d’s WindowHandler
trait instead of
speedy2d’s. This will
give you access to a egui_ctx
context where you can do your GUI
rendering.
struct MyWindowHandler;
impl egui_speedy2d::WindowHandler for MyWindowHandler {
fn on_draw(
&mut self,
helper: &mut WindowHelper,
graphics: &mut Graphics2D,
egui_ctx: &egui::Context,
) {
graphics.clear_screen(Color::WHITE);
egui::Window::new("Hello").show(&egui_ctx, |ui| {
ui.label("World !");
});
}
}
When running the speedy2d Window
, wrap your handler
struct in a WindowHandler
to make it compatible with Speedy2d’s
speedy2d::windows::WindowHandler
trait.
fn main() {
let window = speedy2d::Window::new_centered("Speedy2D: Hello World", (640, 240)).unwrap();
window.run_loop(egui_speedy2d::WindowWrapper::new(MyWindowHandler{}))
}
Re-exports§
pub use egui;
Structs§
- Window
Wrapper - Wraps an egui context with features that are useful for integrating egui with Speedy2d.
Traits§
- Window
Handler - A trait analogous to
speedy2d::window::WindowHandler
, but with the addition of aegui_ctx
argument.