egui-sdl2 0.2.3

egui + SDL2: event handling and rendering via OpenGL or Canvas or WebGPU
Documentation

CI Dependencies crates.io Documentation MIT Apache

egui-sdl2

This crate provides integration between egui and sdl2, inluding event handling and multiple rendering backends with a consistent API. It supports optinal rendering backends:

  • Software rendering via Canvas (canvas-backend feature)
  • OpengGL via glow (glow-backend feature)
  • WebgGPU via wgpu (wgpu-backend feature)

The implementation is based on the design of the official egui-winit, egui_glow, egui-wgpu crates, aming to make it easy to use SDL2 with egui.

Both egui and sdl2 are re-exported for convenience. The sdl2 re-export includes all feature flags available to use.

Usage

To get started, create an EguiGlow or 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:

cargo run --example canvas