A sub-millisecond terminal text rendering system for WebGL2 and OpenGL 3.3
A sub-millisecond terminal text rendering system for WebGL2 and OpenGL 3.3
A high-performance terminal rendering library targeting sub-millisecond render times, supporting both WebGL2 and OpenGL 3.3 from a single Rust codebase. beamterm is a terminal renderer, not a full terminal emulator - it handles the display layer while you provide the terminal logic (see the terminal emulator example for a demo of a working terminal that outperforms several established emulators in rendering throughput). It also powers Ratzilla's WebGL2 backend. The included terminal emulator example running with a dynamic font atlas (Hack + Noto Color Emoji).
Check out interactive examples showcasing both pure WASM applications and JavaScript/TypeScript integrations.
beamterm targets sub-millisecond render times across a wide range of hardware. The following measurements were taken in Chrome (WebGL2/WASM):
| Metric | Target (Low-end) | Achieved (2019 hardware) |
|---|---|---|
| Render Time† | = ...; | |
| terminal.update_cells(cells.into_iter())?; | ||
| terminal.render_frame()?; |
// Handle resize terminal.resize(new_width, new_height)?;
### Selection and Mouse Input
The renderer supports mouse-driven text selection with automatic clipboard integration:
```rust
// Enable selection handler with options
let terminal = Terminal::builder("#canvas")
.mouse_selection_handler(
MouseSelectOptions::new()
.selection_mode(SelectionMode::Linear)
.trim_trailing_whitespace(true),
)
.build()?;
// Or implement custom mouse handling
let terminal = Terminal::builder("#canvas")
.mouse_input_handler(|event, grid| {
// Custom handler logic
})
.build()?;
…
rust
// Static atlas (default, or with custom atlas)
let terminal = Terminal::builder("#canvas").build()?;
let terminal = Terminal::builder("#canvas")
.font_atlas(FontAtlasData::from_binary(include_bytes!("custom.atlas"))?)
.build()?;
// Dynamic atlas (WASM)
let terminal = Terminal::builder("#canvas")
.dynamic_font_atlas(&["JetBrains Mono", "Fira Code"], 16.0)
.build()?;
// Switch atlas at runtime (WASM)
terminal.replace_with_dynamic_atlas(&["Hack", "Fira Code"], 14.0)?;
terminal.replace_with_static_atlas(new_atlas_data)?;Native dynamic atlas usage (requires native-dynamic-atlas feature on beamterm-core):
use beamterm_core::{NativeGlyphRasterizer, gl::DynamicFontAtlas};
let effective_font_size = 16.0 * pixel_ratio;
let rasterizer = NativeGlyphRasterizer::new(
&["Hack Nerd Font Mono", "Hack", "Noto Color Emoji"],
effective_font_size,
)?;
let atlas = DynamicFontAtlas::new(&gl, rasterizer, 16.0, pixel_ratio)?;
let mut grid = TerminalGrid::new(&gl, atlas.into(), size, pixel_ratio, &GlslVersion::Gl330)?;
…
layer = slot / 32
position = slot % 32
…
Byte Layout: [0][1][2][3][4][5][6][7]
└┬─┘ └──┬──┘ └──┬──┘
Glyph ID FG RGB BG RGB
(16-bit) (24-bit) (24-bit)
…
toml
[dependencies]
beamterm-core = "0.15"
glow = "0.16"Any crate that provides a glow::Context works - glutin, sdl2, glfw, etc.
# Install Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add wasm32-unknown-unknown
# Install tools
cargo install wasm-pack trunkNative OpenGL 3.3 examples run directly with cargo:
# Simple terminal rendering demo (glutin + winit)
cargo run -p native-terminal
# Terminal emulator with PTY support (vt100 + portable-pty)
cargo run -p terminal-emulator
# Semi-transparent terminal overlay on a 3D spinning cube
cargo run -p game-console
# Run with dynamic font atlas (rasterizes system fonts at runtime)
cargo run -p native-terminal --features dynamicWASM/browser examples require Trunk:
# Wave interference effect (ratzilla + tachyonfx)
cd examples/canvas_waves && trunk serveNo open issues yet, or sync has not completed.