Expand description
GPU rendering backend for retroglyph: native OpenGL 3.3 core and browser WebGL2, from a single
codebase via [glow].
§Architecture
GlBackendBuilder holds configuration (fonts, grid size, integer scale) and
builds a GlRenderer. The glyph source is a static
FontChain (a single BitmapFont is a chain of one); every font in the chain is
grid-packed into one TEXTURE_2D_ARRAY atlas and addressed by a flat slot id (issue #367’s
grid-packing half, lifting the 256-layer cap). The renderer maintains
per-layer CPU-side instance arrays (one entry per cell: glyph slot + fg/bg RGB + flags) and a GL
context that is created lazily when the windowing loop calls
Presenter::init_surface:
GlBackendBuilder (font, grid size, scale)
| .build()
v
GlRenderer
implements retroglyph_window::Presenter (an Output supertrait)
wrapped by retroglyph_window::WindowBackend to become a full Backend
(WindowBackend owns the input event queue and the no-op Cursor)
|
| init_surface(window) -> GlContext (glutin native / WebGL2 wasm) + GlResources
v
two instanced passes (backgrounds, then coverage-blended glyphs) per grid layer per present():
a unit quad instanced cols*rows times, sampling an R8 glyph atlas (TEXTURE_2D_ARRAY).This backend composites grid layers itself on the GPU
(composites_layers returns true): it
receives the raw layered stream from the core Terminal and draws each layer back-to-front, so
an empty cell in a higher layer lets the layer beneath show through while an occupied cell is
opaque (issue #368), matching retroglyph-software’s per-pixel occlusion. It requests full
frames
(needs_full_frame returns true) and
redraws every cell of every layer each frame, so there is no orphaned-pixel problem from
sub-cell glyph spill.
§Platform split
Native builds create the GL context from the window’s raw handles via glutin
(context_native.rs); wasm builds acquire a WebGL2 context from the winit <canvas>
(context_wasm.rs). Both expose the same internal GlContext API, so the renderer body has no
cfg.
§Features
This crate has no default features; every feature below is optional and off unless enabled.
§default-font
⚪ Optional.
Embeds the Unscii 16 default font so a caller can build a renderer with no font of its own.
Forwards to retroglyph-window’s default-font feature.
§dev
⚪ Optional.
Forwards retroglyph-core’s dev feature, which forces development diagnostics on in a build
that would otherwise compile them out (see retroglyph_core::dev).
§tilesets
⚪ Optional.
PNG sprite/tileset support (issue #366): decodes sprite sheets into an RGBA TEXTURE_2D_ARRAY
atlas and draws them in a second, source-over blended pass.
Forwards to retroglyph-window’s shared tileset decode.
Re-exports§
pub use config::GlBackendBuilder;pub use config::GlBackendError;
Modules§
- config
- Configuration, builder, and error types for the GL backend.
- font
- Bitmap glyph fonts and CP437 mapping, shared by retroglyph’s graphical backends.
Structs§
- Bitmap
Font - A 1-bit-per-pixel bitmap glyph font.
- Font
Chain - The glyph source a backend draws from: a primary
BitmapFontplus an ordered list of fallback fonts. - GlRenderer
- The live GL renderer: a
Presenter, wrapped inWindowBackendto form a fullBackendfor the windowing loop.
Enums§
- Surface
Error - A failure creating or driving the GL context/surface.