Class: Framebuffer


Class represents framebuffer.

new module:og/webgl/Framebuffer.Framebuffer(handler, options)

Name Type Description
handler Handler WebGL handler.
options Object optional Framebuffer options:
Name Type Default Description
width number optional Framebuffer width. Default is handler canvas width.
height number optional Framebuffer height. Default is handler canvas height.
size number optional Color attachment size.
internalFormat String "RGBA" optional Specifies the color components in the texture.
format String "RGBA" optional Specifies the format of the texel data.
type String "UNSIGNED_BYTE" optional Specifies the data type of the texel data.
depthComponent String "DEPTH_COMPONENT16" optional Specifies depth buffer size.
useDepth Boolean optional Using depth buffer during the rendering.



WebGL handler.


Framebuffer texture.



Activate framebuffer frame to draw.
Type Description
Framebuffer Returns Current framebuffer.


Bind buffer texture.
Name Type Default Description
attachmentIndex Number 0 optional color attachment index.
Deactivate framebuffer frame.
Gets JavaScript image object that framebuffer has drawn.
Type Description
Object -


Returns framebuffer completed.
Type Description
boolean -
Open dialog window with framebuffer image.

readAllPixels(res, attachmentIndex)

Reads all pixels(RGBA colors) from framebuffer.
Name Type Default Description
res Uint8Array Result array.
attachmentIndex Number 0 optional color attachment index.

readPixels(res, nx, ny, w, h, attachmentIndex)

Gets pixel RBGA color from framebuffer by coordinates.
Name Type Default Description
res Uint8Array Normalized x - coordinate.
nx number Normalized x - coordinate.
ny number Normalized y - coordinate.
w number 1 optional Normalized width.
h number 1 optional Normalized height.
attachmentIndex Number 0 optional color attachment index.

setSize(width, height)

Sets framebuffer viewport size.
Name Type Description
width number Framebuffer width.
height number Framebuffer height.