Documentation generator: JsDoc Toolkit 2.4.0
Template: Codeview 1.2
Generated on: 2012-11-19 0:05

Class SpiderGL.WebGL.Framebuffer

The SpiderGL.WebGL.Framebuffer is a wrapper for WebGLFramebuffer.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates a SpiderGL.WebGL.Framebuffer.
Field Summary
Field Attributes Field Name and Description
 
Automatic viewport settings in a call to bind.
<readonly>  
Gets/Sets the resource attached to the color attachment.
<static>  
SpiderGL.WebGL.Framebuffer.DEFAULT_ATTACHMENT_CUBE_MAP_FACE
Default texture cube map face to attach when using SpiderGL.WebGL.Framebuffer#setAttachments.
<static>  
SpiderGL.WebGL.Framebuffer.DEFAULT_ATTACHMENT_TEXTURE_LEVEL
Default texture level to attach when using SpiderGL.WebGL.Framebuffer#setAttachments.
<static>  
SpiderGL.WebGL.Framebuffer.DEFAULT_AUTO_VIEWPORT
Default value for SpiderGL.WebGL.Framebuffer#autoViewport.
<static>  
SpiderGL.WebGL.Framebuffer.DEFAULT_CLEAR_MASK
The WebGL birfield mask used for clearing the framebuffer.
<static>  
SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_FORMAT
The WebGL pixel format for reading framebuffer pixels.
<static>  
SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_HEIGHT
Default read rectangle height (in pixels).
<static>  
SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_TYPE
The WebGL pixel type for reading framebuffer pixels.
<static>  
SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_WIDTH
Default read rectangle width (in pixels).
<static>  
SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_X
Default read rectangle left coordinate (in pixels).
<static>  
SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_Y
Default read rectangle bottom coordinate (in pixels).
<readonly>  
Gets/Sets the resource attached to the depthStencil attachment.
<readonly>  
Gets/Sets the resource attached to the depth attachment.
<readonly>  
Gets the height of the attached resources.
<readonly>  
Indicates if the the status of the framebuffer is WebGLRenderingContext.FRAMEBUFFER_COMPLETE.
<readonly>  
Tests if the framebuffer is ready to use.
<readonly>  
The WebGL status of the framebuffer.
<readonly>  
Gets/Sets the resource attached to the stencil attachment.
<static>  
SpiderGL.WebGL.Framebuffer.TARGET
WebGL target for framebuffers.
<readonly>  
Gets a 4-component array with the viewport parameters.
<readonly>  
Gets the width of the attached resources.
Fields borrowed from class SpiderGL.WebGL.ObjectGL:
gl, handle, isValid, target
Fields borrowed from class SpiderGL.Core.ObjectBase:
uid

Method Summary

Method Attributes Method Name and Description
 
Sets the WebGL viewport to the framebuffer viewport rectangle.
 
bind(setViewport)
Binds the wrapped WebGLFramebuffer to the WebGLRenderingContex.FRAMEBUFFER target.
 
clear(mask)
Clears the framebuffer using current clear values.
 
Destroys the WebGLFramebuffer.
 
Detaches all attached resources.
 
Retrieves the attached resources.
 
readPixels(buffer, options)
Reads the pixels from a rectangular region of the framebuffer.
 
setAttachments(attachments)
Sets the framebuffer attachments.
 
Binds "null" to the WebGLRenderingContex.FRAMEBUFFER target.
<static>  
SpiderGL.WebGL.Framebuffer.unbind(gl)
WebGLFramebuffer unbinding.

Class Detail

SpiderGL.WebGL.Framebuffer(gl, options)
Creates a SpiderGL.WebGL.Framebuffer. SpiderGL.WebGL.Framebuffer wraps a WebGLFramebuffer object.
Parameters:
{WebGLRenderingContext} gl
A WebGLRenderingContext hijacked with SpiderGL.WebGL.Context.hijack.
{object} options Optional
Optional parameters.
{WebGLFramebuffer} options.handle Optional
A WebGLFramebuffer. If present, this object will be used as the wrapped WebGLFramebuffer. Otherwise a new one will be created.
{bool} options.autoViewport Optional, Default: SpiderGL.WebGL.Framebuffer.DEFAULT_AUTO_VIEWPORT
The value of the autoViewport property.
{object} options.color Optional
Color attachment target (see setAttachments).
{object} options.depth Optional
Depth attachment target (see setAttachments).
{object} options.stencil Optional
Stencil attachment target (see setAttachments).
{object} options.depthStencil Optional
Depth-Stencil attachment target (see setAttachments).
See:
setAttachments
SpiderGL.WebGL.Texture2D
SpiderGL.WebGL.TextureCubeMap
SpiderGL.WebGL.Renderbuffer
SpiderGL.WebGL.ObjectGL

Field Detail

{bool} autoViewport
Automatic viewport settings in a call to bind. If true, when calling bind the viewport will be set with a call to WebGLRenderingContext.viewport().
Gets/Sets the resource attached to the color attachment. If no resource is attached the result is null. When setting, default attaching parameters are used.
See:
depthTarget
stencilTarget
depthStencilTarget
<static> {number} SpiderGL.WebGL.Framebuffer.DEFAULT_ATTACHMENT_CUBE_MAP_FACE
Default texture cube map face to attach when using SpiderGL.WebGL.Framebuffer#setAttachments.
Default Value:
WebGLRenderingContext.TEXTURE_CUBE_MAP_POSITIVE_X
<static> {number} SpiderGL.WebGL.Framebuffer.DEFAULT_ATTACHMENT_TEXTURE_LEVEL
Default texture level to attach when using SpiderGL.WebGL.Framebuffer#setAttachments.
Default Value:
0
<static> {bool} SpiderGL.WebGL.Framebuffer.DEFAULT_AUTO_VIEWPORT
Default value for SpiderGL.WebGL.Framebuffer#autoViewport.
Default Value:
true
<static> {number} SpiderGL.WebGL.Framebuffer.DEFAULT_CLEAR_MASK
The WebGL birfield mask used for clearing the framebuffer.
See:
SpiderGL.WebGL.Framebuffer#clear
Default Value:
(WebGLRenderingContext.COLOR_BUFFER_BIT | WebGLRenderingContext.DEPTH_BUFFER_BIT | WebGLRenderingContext.STENCIL_BUFFER_BIT)
<static> {number} SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_FORMAT
The WebGL pixel format for reading framebuffer pixels.
See:
SpiderGL.WebGL.Framebuffer#readPixels
Default Value:
WebGLRenderingContext.RGBA
<static> {number} SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_HEIGHT
Default read rectangle height (in pixels). If less than zero, the height will be set to span the whole render target (starting from read rectangle y coordinate).
See:
SpiderGL.WebGL.Framebuffer#readPixels
Default Value:
-1
<static> {number} SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_TYPE
The WebGL pixel type for reading framebuffer pixels.
See:
SpiderGL.WebGL.Framebuffer#readPixels
Default Value:
WebGLRenderingContext.UNSIGNED_BYTE
<static> {number} SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_WIDTH
Default read rectangle width (in pixels). If less than zero, the width will be set to span the whole render target (starting from read rectangle x coordinate).
See:
SpiderGL.WebGL.Framebuffer#readPixels
Default Value:
-1
<static> {number} SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_X
Default read rectangle left coordinate (in pixels).
See:
SpiderGL.WebGL.Framebuffer#readPixels
Default Value:
0
<static> {number} SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_Y
Default read rectangle bottom coordinate (in pixels).
See:
SpiderGL.WebGL.Framebuffer#readPixels
Default Value:
0
<readonly> {SpiderGL.WebGL.Texture|SpiderGL.WebGL.Renderbuffer} depthStencilTarget
Gets/Sets the resource attached to the depthStencil attachment. If no resource is attached the result is null. When setting, default attaching parameters are used.
See:
colorTarget
depthTarget
stencilTarget
Gets/Sets the resource attached to the depth attachment. If no resource is attached the result is null. When setting, default attaching parameters are used.
See:
colorTarget
stencilTarget
depthStencilTarget
<readonly> {number} height
Gets the height of the attached resources. The value represents the height of the attached resources. It is equal to viewport[3].
See:
width
viewport
<readonly> {number} isComplete
Indicates if the the status of the framebuffer is WebGLRenderingContext.FRAMEBUFFER_COMPLETE.
<readonly> {bool} isReady
Tests if the framebuffer is ready to use. A framebuffer is considered ready if its status is WebGLRenderingContext.FRAMEBUFFER_COMPLETE.
See:
isComplete
<readonly> {number} status
The WebGL status of the framebuffer.
See:
isComplete
Gets/Sets the resource attached to the stencil attachment. If no resource is attached the result is null. When setting, default attaching parameters are used.
See:
colorTarget
depthTarget
depthStencilTarget
<static> {number} SpiderGL.WebGL.Framebuffer.TARGET
WebGL target for framebuffers.
Default Value:
WebGLRenderingContext.FRAMEBUFFER
<readonly> {array} viewport
Gets a 4-component array with the viewport parameters. Viewport parameters are stored as [0, 0, width, height] and will be set using WebGLRenderingContext.viewport() during a bind call if autoViewport is true. The width and height parameters corresponds to the width and height of the last resource attached with setAttachments.
See:
autoViewport
setAttachments
<readonly> {number} width
Gets the width of the attached resources. The value represents the width of the attached resources. It is equal to viewport[2].
See:
height
viewport

Method Detail

  • applyViewport()
    Sets the WebGL viewport to the framebuffer viewport rectangle.
    See:
    viewport
    autoViewport
    setAttachments
  • bind(setViewport)
    Binds the wrapped WebGLFramebuffer to the WebGLRenderingContex.FRAMEBUFFER target. If setViewport is not specified and autoViewport is true, the stored viewport is set with WebGLRenderingContext.viewport().
    Parameters:
    {bool} setViewport Optional
    If specified, overrides the value of autoViewport.
    See:
    unbind
    autoViewport
  • clear(mask)
    Clears the framebuffer using current clear values.
    Parameters:
    {number} mask
    The clear mask as for WebGLRenderingContext.clear.
  • destroy()
    Destroys the WebGLFramebuffer. After destruction, the handle is set to null and this object should not be used anymore.
    See:
    SpiderGL.WebGL.ObjectGL#destroy
  • detachAll()
    Detaches all attached resources.
    See:
    setAttachments
  • {object} getAttachments()
    Retrieves the attached resources. This method returns a new object containing the attachments information.
    Returns:
    {object} The attachments data. The object fields may be: color, depth, stencil and depthStencil.
    See:
    setAttachments
  • readPixels(buffer, options)
    Reads the pixels from a rectangular region of the framebuffer.
    Parameters:
    {ArrayBufferView} buffer
    The destination buffer in which pixels will be written.
    {object} options Optional
    Optional parameters.
    {number} options.x Optional, Default: SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_X
    The rectangle left coordinate (in pixels).
    {number} options.y Optional, Default: SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_X
    The rectangle bottom coordinate (in pixels).
    {number} options.width Optional, Default: SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_WIDTH
    The rectangle width (in pixels). If less than zero, the width will be set to span the whole render target (starting from rectangle x coordinate).
    {number} options.height Optional, Default: SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_HEIGHT
    The rectangle height (in pixels). If less than zero, the height will be set to span the whole render target (starting from rectangle y coordinate).
    {number} options.format Optional, Default: SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_FORMAT
    The WebGL pixel format.
    {number} options.type Optional, Default: SpiderGL.WebGL.Framebuffer.DEFAULT_READ_PIXELS_TYPE
    The WebGL pixel type.
  • {bool} setAttachments(attachments)
    Sets the framebuffer attachments. It is used to attach resources (SpiderGL.WebGL.Texture2D, SpiderGL.WebGL.TextureCubeMap or SpiderGL.WebGL.Renderbuffer) as render targets.
    var t2D = new SpiderGL.WebGL.Texture2D(...);
    var tCM = new SpiderGL.WebGL.TextureCubeMap(...);
    var rb  = new SpiderGL.WebGL.Renderbuffer(...);
    
    var fb = new SpiderGL.WebGL.Framebuffer(gl, {
    	color : {resource: t2D, level: 0 }, // alternatively: color: t2D; in this case level would default to SpiderGL.WebGL.Framebuffer.DEFAULT_ATTACHMENT_TEXTURE_LEVEL
    	depth : rb                          // alternatively: depth: {resource: rb}; renderbuffers do not have mipmap levels
    };
    // use fb
    // ...
    
    // change attachment
    fb.setAttachments({
    	color: {resource: tCM, face: gl.TEXTURE_CUBE_MAP_NEGATIVE_Z} // if face is omitted, defaults to SpiderGL.WebGL.Framebuffer.DEFAULT_ATTACHMENT_CUBE_MAP_FACE
    })
    Parameters:
    {object} attachments
    The resources to attach to the WebGLFramebuffer.
    {object|SpiderGL.WebGL.Texture2D|SpiderGL.WebGL.TextureCubeMap|SpiderGL.WebGL.Renderbuffer} attachments.color Optional
    The color attachment for target WebGLRenderingContext.COLOR_ATTACHMENT0; if omitted, the current color attachment is kept; if null, the current color attachment is detached.
    {SpiderGL.WebGL.Texture2D|SpiderGL.WebGL.TextureCubeMap|SpiderGL.WebGL.Renderbuffer} attachments.color.resource Optional
    The resource to use as a render target for color attachment.
    {number} attachments.color.level Optional, Default: SpiderGL.WebGL.Framebuffer.DEFAULT_ATTACHMENT_TEXTURE_LEVEL
    If resource is SpiderGL.WebGL.Texture2D or SpiderGL.WebGL.TextureCubeMap, specifies the texture level to attach. As per WebGL specifications, level must be zero.
    {number} attachments.color.face Optional, Default: SpiderGL.WebGL.Framebuffer.DEFAULT_ATTACHMENT_CUBE_MAP_FACE
    If resource is SpiderGL.WebGL.TextureCubeMap, specifies the texture cube map face to attach.
    {object|SpiderGL.WebGL.Renderbuffer} attachments.depth Optional
    Same as attachments.color but for WebGLRenderingContext.DEPTH_ATTACHMENT. To ensure the restrictions of the WebGL specifications, stencil and depthStencil attachments are detached.
    {object|SpiderGL.WebGL.Renderbuffer} attachments.stencil Optional
    Same as attachments.color but for WebGLRenderingContext.STENCIL_ATTACHMENT. To ensure the restrictions of the WebGL specifications, depth and depthStencil attachments are detached.
    {object|SpiderGL.WebGL.Renderbuffer} attachments.depthStencil Optional
    Same as attachments.color but for WebGLRenderingContext.DEPTH_STENCIL_ATTACHMENT. To ensure the restrictions of the WebGL specifications, depth and stencil attachments are detached.
    Returns:
    {bool} True if the framebuffer is complete, false otherwise.
    See:
    getAttachments
  • unbind()
    Binds "null" to the WebGLRenderingContex.FRAMEBUFFER target. This method is provided only for simmetry with bind and is not relative to the object state.
    See:
    bind
  • <static> SpiderGL.WebGL.Framebuffer.unbind(gl)
    WebGLFramebuffer unbinding. This function binds the null framebuffer to the WebGLRenderingContext.FRAMEBUFFER target.
    Parameters:
    {WebGLRenderingContext} gl
    A WebGLRenderingContext.