Framebuffer

Class represents framebuffer.

Constructor

new Framebuffer(handler, optionsopt)

Parameters:
NameTypeAttributesDescription
handlerHandler

WebGL handler.

optionsIFrameBufferParams<optional>

Framebuffer options:

Methods

bindOutputTexture(texture, glAttachmentopt)

Bind buffer texture.

Parameters:
NameTypeAttributesDefaultDescription
textureWebGLTexture

Output texture.

glAttachmentnumber<optional>
0

color attachment index.

getImage() → {HTMLImageElement}

Gets JavaScript image that in the framebuffer.

Returns:
Type: 
HTMLImageElement

init()

Framebuffer initialization.

readAllPixels(res, attachmentIndexopt)

Reads all pixels(RGBA colors) from framebuffer.

Parameters:
NameTypeAttributesDefaultDescription
resUint8Array

Result array.

attachmentIndexnumber<optional>
0

color attachment index.

readPixels(res, nx, ny, wopt, hopt, indexopt)

Gets pixel RGBA color from framebuffer by coordinates.

Parameters:
NameTypeAttributesDefaultDescription
resUint8Array

Normalized x - coordinate.

nxnumber

Normalized x - coordinate.

nynumber

Normalized y - coordinate.

wnumber<optional>
1

Normalized width.

hnumber<optional>
1

Normalized height.

indexnumber<optional>
0

color attachment index.