Skip to main content

TextRenderer

Low-level WebGPU text pass bound to an IGlyphAtlas implementation (bitmap or MSDF). Consumes packed glyph instance floats prepared by TextLayer / layoutTextLabels.

Import

import { TextRenderer, type TextRendererOptions } from "stratum-map";

Construction

TextRenderer.create(options: TextRendererOptions)

FieldTypeDescription
deviceGPUDeviceWebGPU device
formatGPUTextureFormatRender target format
atlasIGlyphAtlasBitmap or MSDF atlas

Methods

MethodSummary
setAtlas(atlas)Swap atlas implementation (caller manages lifetime)
setInstanceData(floats, count)Upload instance buffer
encodeRenderPass(pass, frame)Encode draw into existing pass
destroy()Release pipelines and buffers

Uniforms

TEXT_FRAME_UNIFORM_BYTE_LENGTH documents the frame block size. Instance stride: TEXT_INSTANCE_FLOAT_STRIDE.

Performance notes

  • Batch instance uploads; avoid resizing GPU buffers every label edit.
  • MSDF path uses median three-channel sampling in WGSL (TEXT_WGSL export for inspection).

See also