Expand description
GPU rendering backend for retroglyph: native OpenGL 3.3 core and browser WebGL2, from a single
codebase via [glow].
§Architecture
config::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::Presenter (an Output supertrait)
wrapped by retroglyph_window::backend::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
(compositing returns
retroglyph_core::backend::Compositing::PixelLayered): 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: 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, and (Linux only, where it’s a
dependency at all) to the retroglyph-software dev-dependency’s own tilesets, so the two
stay in lockstep: without this, cargo test -p retroglyph-gl (this feature off) still pulls in
retroglyph-window/tilesets transitively through that dev-dependency’s forced-on tilesets
below, and the PresenterBuilder impl’s tileset method (gated on this crate’s own tilesets
feature, matching every other tileset-gated item in this crate) would then be missing an item
the trait requires whenever retroglyph-window/tilesets is on, regardless of this crate’s own
flag (retroglyph#1192). Harmless outside a test build: retroglyph-software is dev-only, so
this half of the forward is a no-op for a plain cargo build/check.
Modules§
- config
- Configuration, builder, and error types for the GL backend.
- error
SurfaceError: the GL backend’s surface-lifecycle error type.- 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.