gl-fbo
WebGL framebuffer object wrapper
Example
Try this in your browser if you have WebGL
var shell = var createFBO = var glslify = var ndarray = var fill = var fillScreen = var createUpdateShader = var createDrawShader = var state updateShader drawShader current = 0 shell shell shell
Result:
Install
Install using npm:
npm install gl-fbo
API
var createFBO = require("gl-fbo")
Constructor
There is currently only one default way to create a Framebuffer object. You can construct a framebuffer using the following syntax:
var fbo = createFBO(gl, shape[, options])
Creates a wrapped framebuffer object
-
gl
is a handle to a WebGL context -
shape
is a length 2 array encoding the[width, height]
of the frame buffer -
options
is an object containing the following optional properties:options.preferFloat
Upgrade to floating point if available, otherwise fallback to 8bit. (defaultfalse
)options.float
Use floating point textures (defaultfalse
)options.color
The number of color buffers to create (default1
)options.depth
If fbo has a depth buffer (default:true
)options.stencil
If fbo has a stencil buffer (default:false
)
Methods
fbo.bind()
Binds the framebuffer object to the display. To rebind the original drawing buffer, you can just call WebGL directly:
//Bind the drawing buffergl
fbo.dispose()
Destroys the framebuffer object and releases all associated resources
Properties
fbo.shape
Returns the shape of the frame buffer object. Writing to this property resizes the framebuffer. For example,
fboshape = newWidth newHeight
fbo.gl
A reference to the WebGL context
fbo.handle
A handle to the underlying Framebuffer object.
fbo.color
An array containing gl-texture2d
objects representing the buffers.
fbo.depth
The depth/stencil component of the FBO. Stored as a gl-texture2d
. If not present, is null
.
Credits
(c) 2013-2014 Mikola Lysenko. MIT License