# retroglyph-wgpu - Complete API Documentation > GPU rendering backend for retroglyph: Vulkan, Metal, D3D12, and WebGPU via wgpu **Version:** 0.0.0 **Authors:** Matan Lurey **License:** MIT **Repository:** https://github.com/crates-lurey-io/retroglyph **Keywords:** roguelike, terminal, grid, gamedev Generated: 2026-08-05 20:21:10 UTC Created by: [cargo-llms-txt](https://github.com/masinc/cargo-llms-txt) ## Table of Contents ### src/error.rs - pub enum SurfaceError - impl fmt::Display for SurfaceError - impl std::error::Error for SurfaceError - impl retroglyph_window::RecoverableError for SurfaceError ### src/lib.rs - pub mod config - pub use config::{WgpuBackendBuilder, WgpuBackendError} - pub use error::SurfaceError - pub use retroglyph_window::font::{self as font, BitmapFont, FontChain} - pub struct WgpuRenderer - impl WgpuRenderer - impl Output for WgpuRenderer - impl Presenter for WgpuRenderer - impl conformance::WgpuObserver - impl Output for conformance::WgpuObserver - impl Observable for conformance::WgpuObserver ### src/config.rs - pub enum WgpuBackendError - impl fmt::Display for WgpuBackendError - impl std::error::Error for WgpuBackendError - pub struct WgpuBackendBuilder - impl Default for WgpuBackendBuilder - impl WgpuBackendBuilder ### src/headless.rs - impl Frame ### src/renderer.rs - impl LayerRange - impl GpuResources - impl SpriteGpu ### src/gpu.rs - impl GpuContext - impl WindowSurface - impl Frame - impl PendingGpu - impl PendingGpu ### src/sprite_set.rs - impl SpriteSlot - impl SpriteInstance - impl SpriteSet ### src/instance.rs - impl Cell --- ## README.md ### retroglyph-wgpu GPU rendering backend for retroglyph: Vulkan, Metal, D3D12, and WebGPU via wgpu Part of the [retroglyph](https://github.com/crates-lurey-io/retroglyph) workspace. --- ## src/error.rs ### SurfaceError ```rust #[derive(Debug)] pub enum SurfaceError { Init(String), Frame(String), DeviceLost(String), } ``` A failure creating or driving the wgpu device and surface. The variants split along the one distinction the event loop acts on: whether retrying is worth anything. [`RecoverableError`](retroglyph_window::RecoverableError) reads that split, and `retroglyph_window::winit::run` uses it to decide between logging-and-continuing and exiting. ### impl fmt::Display for SurfaceError ```rust impl fmt::Display for SurfaceError { } ``` ### impl std::error::Error for SurfaceError ```rust impl std::error::Error for SurfaceError { } ``` ### impl retroglyph_window::RecoverableError for SurfaceError ```rust impl retroglyph_window::RecoverableError for SurfaceError { } ``` ## src/lib.rs ### config::{WgpuBackendBuilder, WgpuBackendError} ```rust pub use config::{WgpuBackendBuilder, WgpuBackendError}; ``` ### error::SurfaceError ```rust pub use error::SurfaceError; ``` ### retroglyph_window::font::{self as font, BitmapFont, FontChain} ```rust pub use retroglyph_window::font::{self as font, BitmapFont, FontChain}; ``` ### WgpuRenderer ```rust pub struct WgpuRenderer { } ``` The live wgpu renderer: a [`Presenter`], wrapped in [`WindowBackend`](retroglyph_window::WindowBackend) to form a full [`Backend`](retroglyph_core::backend::Backend) for the windowing loop. It does not implement [`Input`](retroglyph_core::backend::Input) or [`Cursor`](retroglyph_core::backend::Cursor) itself: a GPU renderer cannot present without a live device, so there is no headless-with-input use for a bare `Terminal`. In windowed use `WindowBackend` owns the input queue (with its `Mouse(Moved)` coalescing) and the no-op cursor, so a duplicate queue here would only ever be dead. See the sub-cell offset note on [`Presenter`] for the shared rendering contract. Build one with [`WgpuBackendBuilder`]. Before the windowing loop calls [`init_surface`](Presenter::init_surface) there is no device; drawing updates only the CPU-side instance arrays, and [`present`](Presenter::present) is a no-op. Once the device exists, `present` uploads the frame and encodes one render pass. ### impl WgpuRenderer ```rust impl WgpuRenderer { } ``` ### impl Output for WgpuRenderer ```rust impl Output for WgpuRenderer { } ``` ### impl Presenter for WgpuRenderer ```rust impl Presenter for WgpuRenderer { } ``` ### impl WgpuObserver ```rust impl WgpuObserver { } ``` ### impl Output for WgpuObserver ```rust impl Output for WgpuObserver { } ``` ### impl Observable for WgpuObserver ```rust impl Observable for WgpuObserver { } ``` ## src/config.rs ### WgpuBackendError ```rust #[derive(Debug)] pub enum WgpuBackendError { NoFont, MixedGlyphSizes, FontChainTooLarge, ZeroScale, ZeroGrid, SurfaceTooLarge, #[cfg(feature = "tilesets")] Tileset(retroglyph_window::tileset::TilesetError), } ``` Errors from configuring the wgpu backend. Every variant is a configuration mistake caught before any GPU work happens; failures from the device itself are [`SurfaceError`](crate::SurfaceError) instead. ### impl fmt::Display for WgpuBackendError ```rust impl fmt::Display for WgpuBackendError { } ``` ### impl std::error::Error for WgpuBackendError ```rust impl std::error::Error for WgpuBackendError { } ``` ### WgpuBackendBuilder ```rust #[derive(Debug, Clone)] pub struct WgpuBackendBuilder { } ``` Builder for the wgpu backend. #### Examples ```no_run use retroglyph_core::color::Style; use retroglyph_wgpu::WgpuBackendBuilder; use retroglyph_window::winit::{WindowConfig, run_windowed}; let renderer = WgpuBackendBuilder::new() .grid_size(80, 25) .scale(2) .build() .expect("wgpu backend init failed"); let config = WindowConfig::fit(&renderer, "My Game", None, true); run_windowed(config, renderer, move |term| { term.draw(|s| s.print((0, 0), "Hello from retroglyph-wgpu!", Style::default())) .ok(); }) .expect("event loop failed"); ``` ### impl Default for WgpuBackendBuilder ```rust impl Default for WgpuBackendBuilder { } ``` ### impl WgpuBackendBuilder ```rust impl WgpuBackendBuilder { pub fn new() -> Self; pub fn grid_size(self, cols: u16, rows: u16) -> Self; pub fn scale(self, scale: u16) -> Self; pub fn font(self, fonts: impl Trait) -> Self; pub fn tileset(self, opts: TilesetOptions) -> Self; pub fn build(self) -> Result; } ``` ## src/headless.rs ### impl Frame ```rust impl Frame { } ``` ## src/renderer.rs ### impl LayerRange ```rust impl LayerRange { } ``` ### impl GpuResources ```rust impl GpuResources { } ``` ### impl SpriteGpu ```rust impl SpriteGpu { } ``` ## src/gpu.rs ### impl GpuContext ```rust impl GpuContext { } ``` ### impl WindowSurface ```rust impl WindowSurface { } ``` ### impl Frame ```rust impl Frame { } ``` ### impl PendingGpu ```rust impl PendingGpu { } ``` ### impl PendingGpu ```rust impl PendingGpu { } ``` ## src/sprite_set.rs ### impl SpriteSlot ```rust impl SpriteSlot { } ``` ### impl SpriteInstance ```rust impl SpriteInstance { } ``` ### impl SpriteSet ```rust impl SpriteSet { } ``` ## src/instance.rs ### impl Cell ```rust impl Cell { } ``` ## src/shaders.rs