Constructor
new Framebuffer(handler, optionsopt)
Name | Type | Attributes | Description |
---|---|---|---|
handler | Handler | WebGL handler. | |
options | IFrameBufferParams | <optional> | Framebuffer options: |
- Source
Methods
bindOutputTexture(texture, glAttachmentopt)
Bind buffer texture.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
texture | WebGLTexture | Output texture. | ||
glAttachment | number | <optional> | 0 | color attachment index. |
- Source
getImage() → {HTMLImageElement}
Gets JavaScript image that in the framebuffer.
- Source
- Type:
- HTMLImageElement
init()
Framebuffer initialization.
- Source
readAllPixels(res, attachmentIndexopt)
Reads all pixels(RGBA colors) from framebuffer.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
res | TypedArray | Result array. | ||
attachmentIndex | number | <optional> | 0 | color attachment index. |
- Source
readData(nx, ny, outData, attachmentIndexopt) → {void}
Reads pixel data from the buffer at the specified normalized coordinates.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
nx | number | Normalized X coordinate in the range [0, 1], multiplied by the buffer width. | ||
ny | number | Normalized Y coordinate in the range [0, 1], multiplied by the buffer height. | ||
outData | NumberArray4 | | Output array where the RGBA pixel values will be written. | ||
attachmentIndex | number | <optional> | 0 | Index of the color attachment (buffer) to read from. |
- Source
- Type:
- void
const color = new Float32Array(4);
framebuffer.readData(0.5, 0.5, color); // Reads the color at the center of the buffer
readPixels(res, nx, ny, wopt, hopt, indexopt)
Gets pixel RGBA color from framebuffer by coordinates.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
res | TypedArray | Normalized x - coordinate. | ||
nx | number | Normalized x - coordinate. | ||
ny | number | Normalized y - coordinate. | ||
w | number | <optional> | 1 | Normalized width. |
h | number | <optional> | 1 | Normalized height. |
index | number | <optional> | 0 | color attachment index. |
- Source