egui-sdl2 0.2.0

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

CI Dependencies crates.io Documentation MIT Apache

egui-sdl2

This crate provides integration between egui and sdl2. It also includes optional OpenGL rendering via glow and software rendering via sdl2::render::Canvas. The implementation is based on the design of the official egui-winit and egui_glow crates.

Features:

  • Translate SDL2 events into [egui] events.
  • Handle [egui::PlatformOutput] (clipboard, cursor updates, links).
  • Render with OpenGL via [glow] (glow-backend feature).
  • Render with the SDL2 software renderer via [sdl2::render::Canvas] (canvas-backend feature).

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 instance to manage rendering. Pass SDL2 events to it, then call run and paint each frame. If you only need event handling, you can use the only State type. Examples are available in the examples/ directory. To run the canvas example:

cargo run --example canvas