egui-sdl2
egui on SDL2: SDL2 event handling plus three swappable rendering backends behind one consistent API.
Why egui-sdl2?
- Three rendering backends, one API. Software (
Canvas), OpenGL (glow), and WebGPU (wgpu) — pick one with a feature flag and use the sameon_event/run/paintloop for all of them. - Tracks the latest egui. Kept in step with current egui releases so you are not stuck on an old version.
- Built on the official design. Mirrors the structure of the upstream
egui-winit,egui_glow, andegui-wgpucrates, so the API feels familiar and behaves predictably. - Batteries included. Translates SDL2 events into egui events and handles
egui::PlatformOutput(clipboard, cursor updates, opening links). Botheguiandsdl2are re-exported for convenience, and thesdl2re-export forwards all of SDL2's feature flags.
Rendering backends
Enable exactly what you need via feature flags:
canvas-backend— software rendering viaCanvasglow-backend— OpenGL viaglowwgpu-backend— WebGPU viawgpu
Usage
// Create SDL2 window and canvas:
let sdl = init.unwrap;
let video = sdl.video.unwrap;
let window = video.window.build.unwrap;
let mut canvas = window.into_canvas.build.unwrap;
// Create egui renderer; the canvas stays yours:
let mut egui = new;
let mut event_pump = sdl.event_pump.unwrap;
loop
To get started, create an EguiGlow,
EguiCanvas, or
EguiWgpu instance to manage rendering.
Pass SDL2 events to on_event, then call run and paint each frame. For event handling only, you can use
the State type.
Examples are available in the examples/
directory. To run the canvas example:
License
Licensed under either of Apache License 2.0 or MIT license at your option.