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

Class SpiderGL.WebGL.VertexBuffer

The SpiderGL.WebGL.VertexBuffer is WebGLBuffer wrapper for vertex buffers.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates a SpiderGL.WebGL.VertexBuffer.
Field Summary
Field Attributes Field Name and Description
<static>  
SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_ENABLE
Default enable flag for vertex attribute when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
<static>  
SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_INDEX
Default vertex attribute index when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
<static>  
SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_NORMALIZED
Default vertex attribute normalized flag when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
<static>  
SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_OFFSET
Default vertex attribute offset when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
<static>  
SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_SIZE
Default vertex attribute size when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
<static>  
SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_STRIDE
Default vertex attribute stride when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
<static>  
SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_TYPE
Default vertex attribute type when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
<static>  
SpiderGL.WebGL.VertexBuffer.TARGET
WebGL target for vertex buffers.
Fields borrowed from class SpiderGL.WebGL.Buffer:
isReady, size, usage
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
<static>  
SpiderGL.WebGL.VertexBuffer.unbind(gl)
WebGLBuffer unbinding for vertex buffers.
 
Latches the WebGL vertex attribute pointer with the internal buffer.
Methods borrowed from class SpiderGL.WebGL.Buffer:
bind
destroy
setData
setSize
setSubData

Class Detail

SpiderGL.WebGL.VertexBuffer(gl, options)
Creates a SpiderGL.WebGL.VertexBuffer. SpiderGL.WebGL.VertexBuffer represents a wrapper for a WebGLBuffer to be bound to the WebGLRenderingContext.ARRAY_BUFFER target.
Parameters:
{WebGLRenderingContext} gl
A WebGLRenderingContext hijacked with SpiderGL.WebGL.Context.hijack.
{object} options Optional
See SpiderGL.WebGL.Buffer.
See:
SpiderGL.WebGL.Buffer
SpiderGL.WebGL.IndexBuffer
SpiderGL.WebGL.ObjectGL

Field Detail

<static> {bool} SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_ENABLE
Default enable flag for vertex attribute when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
Default Value:
true
<static> {number} SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_INDEX
Default vertex attribute index when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
Default Value:
0
<static> {bool} SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_NORMALIZED
Default vertex attribute normalized flag when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
Default Value:
false
<static> {number} SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_OFFSET
Default vertex attribute offset when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
Default Value:
0
<static> {number} SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_SIZE
Default vertex attribute size when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
Default Value:
3
<static> {number} SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_STRIDE
Default vertex attribute stride when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
Default Value:
0
<static> {number} SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_TYPE
Default vertex attribute type when using SpiderGL.WebGL.VertexBuffer#vertexAttribPointer.
Default Value:
WebGLRenderingContext.FLOAT
<static> {number} SpiderGL.WebGL.VertexBuffer.TARGET
WebGL target for vertex buffers.
Default Value:
WebGLRenderingContext.ARRAY_BUFFER

Method Detail

  • <static> SpiderGL.WebGL.VertexBuffer.unbind(gl)
    WebGLBuffer unbinding for vertex buffers. This function binds the null buffer to the WebGLRenderingContext.ARRAY_BUFFER target.
    Parameters:
    {WebGLRenderingContext} gl
    A WebGLRenderingContext.
  • vertexAttribPointer(options)
    Latches the WebGL vertex attribute pointer with the internal buffer. The effect of this method is to bind the SpiderGL.WebGL.VertexBuffer and call WebGLRenderingContext.vertexAttribPointer() with the provided parameters.
    var vb = new SpiderGL.WebGL.VertexBuffer(...); // create a vertex buffer
    // [... set vb data ...]
    // calling vb.vertexAttribPointer has the same effect of:
    // vb.bind();
    // gl.vertexAttribPointer(positionAttributeIndex, 3, gl.FLOAT, false, 0, 0);
    // gl.enableVertexAttribArray(positionAttributeIndex);
    vb.vertexAttribPointer({
    	index      : positionAttributeIndex,  // if omitted, defaults to SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_INDEX
    	size       : 3,         // if omitted, defaults to SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_SIZE
    	glType     : gl.FLOAT,  // if omitted, defaults to SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_TYPE
    	normalized : false,     // if omitted, defaults to SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_NORMALIZED
    	stride     : 0,         // if omitted, defaults to SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_STRIDE
    	offset     : 0,         // if omitted, defaults to SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_OFFSET
    	enable     : true       // if omitted, defaults to SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_ENABLE
    });
    Parameters:
    {object} options Optional
    Vertex attribute pointer parameters.
    {number} options.index Optional, Default: SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_INDEX
    Attribute index.
    {number} options.size Optional, Default: SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_SIZE
    Attribute size.
    {number} options.type Optional, Default: SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_TYPE
    Attribute base type.
    {number} options.normalized Optional, Default: SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_NORMALIZED
    True if the attribute has an integer type and must be normalized.
    {number} options.stride Optional, Default: SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_STRIDE
    Bytes from the beginning of an element and the beginning of the next one.
    {number} options.offset Optional, Default: SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_OFFSET
    Offset (in bytes) from the start of the buffer.
    {bool} options.enable Optional, Default: SpiderGL.WebGL.VertexBuffer.DEFAULT_ATTRIBUTE_ENABLE
    If true, the index-th vertex attribute array will be enabled with WebGLRenderingContext.enableVertexAttribArray(index).