# retroglyph-gl - Complete API Documentation > GPU rendering backend for retroglyph: OpenGL 3.3 (native) and WebGL2 (wasm) via glow **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/sprites.rs - impl SpriteSlot - impl SpriteInstance - impl SpriteSet ### 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::{GlBackendBuilder, GlBackendError} - pub use error::SurfaceError - pub use retroglyph_window::font::{self as font, BitmapFont, FontChain} - pub struct GlRenderer - impl GlRenderer - impl Output for GlRenderer - impl Presenter for GlRenderer - impl Drop for GlRenderer - impl output_conformance_tests::GlObserver - impl Output for output_conformance_tests::GlObserver - impl Observable for output_conformance_tests::GlObserver ### src/context_native.rs - impl GlContext ### src/config.rs - pub enum GlBackendError - impl fmt::Display for GlBackendError - impl std::error::Error for GlBackendError - pub struct GlBackendBuilder - impl Default for GlBackendBuilder - impl GlBackendBuilder ### src/headless.rs - impl HeadlessContext - impl Frame ### src/webgl_recovery.rs - impl raw_window_handle::HasWindowHandle for NoWindow - impl raw_window_handle::HasDisplayHandle for NoWindow ### src/renderer.rs - impl Instance - impl GlResources - impl SpriteGpu ### src/context_wasm.rs - impl ContextLoss - impl Drop for ContextLoss - impl GlContext ### src/webgl_smoke.rs - impl Frame --- ## README.md ### retroglyph-gl GPU rendering backend for retroglyph: OpenGL 3.3 (native) and WebGL2 (wasm) via glow Part of the [retroglyph](https://github.com/crates-lurey-io/retroglyph) workspace. --- ## src/sprites.rs ### impl SpriteSlot ```rust impl SpriteSlot { } ``` ### impl SpriteInstance ```rust impl SpriteInstance { } ``` ### impl SpriteSet ```rust impl SpriteSet { } ``` ## src/error.rs ### SurfaceError ```rust #[derive(Debug)] pub enum SurfaceError { Init(String), Present(String), } ``` A failure creating or driving the GL context/surface. Both the native (glutin) and wasm (WebGL2) context modules produce this. It is string-backed rather than a structured enum because the two platforms surface very different underlying error types (glutin's `glutin::error::Error` vs. a `web_sys` `JsValue`), and the caller ([`retroglyph_window`]'s event loop) only needs a message plus the recoverable/fatal signal from [`RecoverableError`](retroglyph_window::RecoverableError). ### 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::{GlBackendBuilder, GlBackendError} ```rust pub use config::{GlBackendBuilder, GlBackendError}; ``` ### 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}; ``` ### GlRenderer ```rust pub struct GlRenderer { } ``` The live GL 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 GL renderer cannot present without a live context, 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 [`GlBackendBuilder`]. Before the windowing loop calls [`init_surface`](Presenter::init_surface) there is no GL context; drawing updates only the CPU-side instance array, and [`present`](Presenter::present) is a no-op. Once the surface exists, `present` uploads changed cells and issues the single instanced draw call. ### impl GlRenderer ```rust impl GlRenderer { } ``` ### impl Output for GlRenderer ```rust impl Output for GlRenderer { } ``` ### impl Presenter for GlRenderer ```rust impl Presenter for GlRenderer { } ``` ### impl Drop for GlRenderer ```rust impl Drop for GlRenderer { } ``` ### impl GlObserver ```rust impl GlObserver { } ``` ### impl Output for GlObserver ```rust impl Output for GlObserver { } ``` ### impl Observable for GlObserver ```rust impl Observable for GlObserver { } ``` ## src/context_native.rs ### impl GlContext ```rust impl GlContext { } ``` ## src/config.rs ### GlBackendError ```rust #[derive(Debug)] pub enum GlBackendError { NoFont, MixedGlyphSizes, FontChainTooLarge, ZeroScale, ZeroGrid, SurfaceTooLarge, #[cfg(feature = "tilesets")] Tileset(retroglyph_window::tileset::TilesetError), } ``` Errors from configuring the GL backend. ### impl fmt::Display for GlBackendError ```rust impl fmt::Display for GlBackendError { } ``` ### impl std::error::Error for GlBackendError ```rust impl std::error::Error for GlBackendError { } ``` ### GlBackendBuilder ```rust #[derive(Debug, Clone)] pub struct GlBackendBuilder { } ``` Builder for the GL backend. #### Examples ```no_run #### #[cfg(not(target_arch = "wasm32"))] #### fn main() { use retroglyph_core::color::Style; use retroglyph_gl::GlBackendBuilder; use retroglyph_window::winit::{WindowConfig, run_windowed}; let renderer = GlBackendBuilder::new() .grid_size(80, 25) .scale(2) .build() .expect("gl 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-gl!", Style::default())) .ok(); }) .expect("event loop failed"); #### } #### #[cfg(target_arch = "wasm32")] #### fn main() {} ``` ### impl Default for GlBackendBuilder ```rust impl Default for GlBackendBuilder { } ``` ### impl GlBackendBuilder ```rust impl GlBackendBuilder { 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 HeadlessContext ```rust impl HeadlessContext { } ``` ### impl Frame ```rust impl Frame { } ``` ## src/webgl_recovery.rs ### impl raw_window_handle::HasWindowHandle for NoWindow ```rust impl raw_window_handle::HasWindowHandle for NoWindow { } ``` ### impl raw_window_handle::HasDisplayHandle for NoWindow ```rust impl raw_window_handle::HasDisplayHandle for NoWindow { } ``` ## src/renderer.rs ### impl Instance ```rust impl Instance { } ``` ### impl GlResources ```rust impl GlResources { } ``` ### impl SpriteGpu ```rust impl SpriteGpu { } ``` ## src/context_wasm.rs ### impl ContextLoss ```rust impl ContextLoss { } ``` ### impl Drop for ContextLoss ```rust impl Drop for ContextLoss { } ``` ### impl GlContext ```rust impl GlContext { } ``` ## src/webgl_smoke.rs ### impl Frame ```rust impl Frame { } ``` ## src/shaders.rs