import { GLfloat2, GLsizei2 } from '../tuples'; import { Camera } from '../camera'; import { ChangeLookup } from '../changelookup'; import { Context } from '../context'; import { Framebuffer } from '../framebuffer'; import { Initializable } from '../initializable'; import { Program } from '../program'; import { GlyphVertices } from './glyphvertices'; import { Label } from './label'; import { LabelGeometry } from './labelgeometry'; /** * This class allows rendering of multiple dynamic as well as static labels. While preparing for frame, all label * geometry is packed into single buffers for the GPU and drawing is done with as few draw calls as possible. The * preparation tries to reduce state changes when labels of same color and same font are provided consecutively. * It might be beneficial to not render labels of large static texts and some often changing dynamic texts using the * same label render pass object. Often changing texts should be out into separate passed for better performance. */ export declare class LabelRenderPass extends Initializable { /** * Default AA step scale: more crisp text rendering (the value is optimized for multi-frame sampling). */ protected static readonly DEFAULT_AA_STEP_SCALE: GLfloat; /** * Alterable auxiliary object for tracking changes on render pass inputs and lazy updates. */ protected readonly _altered: ChangeLookup & { any: boolean; camera: boolean; geometry: boolean; labels: boolean; aaStepScale: boolean; aaSampling: boolean; }; /** * Context, used to get context information and WebGL API access. */ protected _context: Context; /** @see {@link target} */ protected _target: Framebuffer; /** @see {@link camera} */ protected _camera: Camera; /** @see {@link ndcOffset} */ protected _ndcOffset: GLfloat2; /** @see {@link depthMask} */ protected _depthMask: boolean; /** @see {@link depthFunc} */ protected _depthFunc: GLenum; /** @see {@link aaStepScale} */ protected _aaStepScale: GLfloat; /** @see {@link aaSampling} */ protected _aaSampling: LabelRenderPass.Sampling; protected _program: Program; protected _uViewProjection: WebGLUniformLocation | undefined; protected _uNdcOffset: WebGLUniformLocation | undefined; protected _uColor: WebGLUniformLocation | undefined; protected _uAAStepScale: WebGLUniformLocation | undefined; protected _uTransform: WebGLUniformLocation | undefined; protected _uDynamic: WebGLUniformLocation | undefined; protected _uAASampling: WebGLUniformLocation | undefined; protected _labels: Label[]; /** * Stores for each label (same index in _labels) the range within the geometry. */ protected _ranges: GLsizei2[]; /** * Stores typeset glyph vertices data per label and is used as cache to avoid unnecessary typesetting. */ protected _verticesPerLabel: (GlyphVertices | undefined)[]; protected _geometry: LabelGeometry; /** * Creates a render pass for labels. * @param context - Valid context to create the object for. */ constructor(context: Context); /** * Typesets and renders 2D and 3D labels. */ protected prepare(): void; protected draw(): void; initialize(): boolean; uninitialize(): void; /** * @param override - If enabled, everything will be updated, regardless of tracked alterations. */ update(override?: boolean): void; /** * This invokes draw calls on all labels. Thereby it aims to avoid unnecessary binds when texture or color does * not change and accumulate draw calls as long as both remain unchanged. Further more, draw calls will be * accumulated as much as possible (static labels only). */ frame(): void; /** * Unbind the label geometry. */ unbind(): void; /** * Sets the framebuffer the quads are rendered to. * @param target - Framebuffer to render into. */ set target(target: Framebuffer); /** * The NDC offset is used for vertex displacement within subpixel space for anti-aliasing over * multiple intermediate frames (multi-frame sampling). * @param offset - Subpixel offset used for vertex displacement (multi-frame anti-aliasing). */ set ndcOffset(offset: GLfloat2); /** * The camera's viewProjection is used for 3D label placement calculation. */ set camera(camera: Camera); /** * Allows to restrict writing into the depth buffer. If the mask is set to `true`, labels might affect the depth * buffer and apply fragment-based discard in order to reduce blank glyph areas to override depth values. If this * mode is used, labels should be the last or one of the later rendering passes. If the mask is set to `false`, the * common transparency/blending etc issues might occur when several labels overlap or other, e.g., transparent * areas are rendered afterwards... However, if only labels of the same color can overlap and no other objects can * interfere, this might be the better choice. * By default, writing to the depth buffer is disabled (depth mask is false). */ set depthMask(flag: boolean); get depthMask(): boolean; /** * Allows to specify the value used for depth buffer comparisons. */ set depthFunc(func: GLenum); get depthFunc(): GLenum; /** * Access to the labels that should be rendered. Note that label preparation is currently done per * label-render pass instance, so drawing the same label with multiple renderers should be avoided. Label * preparation will be invoked on update, iff the labels or the font face have changed. */ set labels(labels: Array