textmode.js / TextmodeFramebuffer
Class: TextmodeFramebuffer
Framebuffer class for managing offscreen rendering targets initialized via Textmodifier.createFramebuffer.
TextmodeFramebuffer instances contain 3 attachments to support the rendering pipeline:
- Attachment 0: Character and transform data (RGBA)
- Attachment 1: Primary color data (RGBA)
- Attachment 2: Secondary color data (RGBA)
Implements
IFramebuffer
Accessors
attachmentCount
Get Signature
get attachmentCount(): number;Get the number of color attachments in this framebuffer
Returns
number
height
Get Signature
get height(): number;Get the height of the framebuffer
Returns
number
Implementation of
IFramebuffer.heighttextures
Get Signature
get textures(): WebGLTexture[];Get the WebGL textures associated with this framebuffer
Returns
WebGLTexture[]
Implementation of
IFramebuffer.textureswidth
Get Signature
get width(): number;Get the width of the framebuffer
Returns
number
Implementation of
IFramebuffer.widthMethods
begin()
begin(): void;Begin drawing to this framebuffer.
This method:
- Flushes any pending draw calls to maintain proper render order
- Saves the current framebuffer and viewport state
- Binds this framebuffer as the render target
- Clears all color attachments to transparent black
- Sets the viewport to match the framebuffer dimensions
All subsequent drawing operations will target this framebuffer until end is called.
Returns
void
Implementation of
IFramebuffer.begindispose()
dispose(): void;Dispose of WebGL resources used by this framebuffer.
This method is idempotent and safe to call multiple times. After disposal, the framebuffer should not be used for rendering.
Returns
void
Implementation of
IFramebuffer.disposeend()
end(): void;End rendering to this framebuffer and restore previous state.
This method:
- Flushes any pending draw calls into this framebuffer
- Restores the previously bound framebuffer
- Restores the previous viewport settings
After calling this method, rendering operations will target the previously active framebuffer.
Returns
void
Implementation of
IFramebuffer.endreadPixels()
readPixels(attachmentIndex): Uint8Array;Read pixels from a specific color attachment into an RGBA Uint8Array.
The returned pixel data:
- Is in RGBA format (4 bytes per pixel)
- Has top-left origin (first pixel is top-left corner)
- Is cached until the next render pass to this framebuffer
Parameters
| Parameter | Type | Description |
|---|---|---|
attachmentIndex | number | The index of the color attachment to read (0-based) 0. Character data and transform info 1. Character colors 2. Cell background colors |
Returns
Uint8Array
A Uint8Array containing the pixel data in RGBA format
Implementation of
IFramebuffer.readPixelsresize()
resize(width, height): void;Resize the framebuffer to new dimensions. This recreates the internal textures with the new size and invalidates any cached pixel data.
Parameters
| Parameter | Type | Description |
|---|---|---|
width | number | New width in pixels/cells |
height | number | New height in pixels/cells |
Returns
void
Implementation of
IFramebuffer.resize