10 breaking releases
Uses new Rust 2024
| 0.11.0 | Mar 10, 2026 |
|---|---|
| 0.9.0 | Aug 10, 2025 |
| 0.8.0 | Sep 22, 2024 |
| 0.6.0 | Feb 4, 2023 |
| 0.1.0 | Apr 12, 2021 |
#1360 in Game dev
Used in 2 crates
20KB
164 lines
gapp-winit
An abstract event loop library for winit-based applications with support for OpenGL/glutin and wgpu backends. Integrates seamlessly with gapp traits for clean separation of input, update, render, and present.
Supports native (Windows/Linux/macOS) and WASM. Fixed-timestep FPS cap, automatic resize handling, multi-window support.
Features
- Multi-window: Manage multiple windows via
Windows<R>collection, with per-window event routing. - Backend-agnostic: Switch between OpenGL and wgpu via Cargo features.
- Trait-based: Implement
WindowInput,Present,Render(gapp),Update(gapp). - Cross-platform: Full WASM support (HTML canvas).
- Performance: Fixed timestep, on-demand redraw, FPS sleep (native).
| Feature | OpenGL | wgpu |
|---|---|---|
| Native | ✅ | ✅ |
| WASM | ✅ | ✅ |
| Default | ✅ | ❎️ |
Quickstart
For reference, have a look at the template program. It also can be used as a base for your program.
Traits Overview
WindowInput<C, R>: Handle allWindowEvents (post-resize/redraw) withWindowIdand&mut Windows<R>. Callevent_loop.exit()on close.Present<R>: Submit frame per window (e.g.,queue.submit(),surface.swap_buffers()).Render<R>/Update(from gapp): Standard render/update loop, called per window.Windows<R>: Collection mappingWindowId→(WindowData, R). Insert/remove windows dynamically.
Resize is auto-handled per window.
FPS can be supplied to run.
Dependencies
~0.6–23MB
~294K SLoC