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

Class SpiderGL.WebGL.IndexBuffer

The SpiderGL.WebGL.IndexBuffer is WebGLBuffer wrapper for index buffers.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates a SpiderGL.WebGL.IndexBuffer.
Field Summary
Field Attributes Field Name and Description
<static>  
SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_COUNT
Default elements count when using SpiderGL.WebGL.IndexBuffer#drawElements.
<static>  
SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_MODE
Default elements draw mode when using SpiderGL.WebGL.IndexBuffer#drawElements.
<static>  
SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_OFFSET
Default index buffer offset when using SpiderGL.WebGL.IndexBuffer#drawElements.
<static>  
SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_TYPE
Default index type when using SpiderGL.WebGL.IndexBuffer#drawElements.
<static>  
SpiderGL.WebGL.IndexBuffer.TARGET
WebGL target for index 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
 
drawElements(options)
Binds the index buffers and calls WebGLRenderingContext.drawElements with the provided parameters.
<static>  
SpiderGL.WebGL.IndexBuffer.unbind(gl)
WebGLBuffer unbinding for index buffers.
Methods borrowed from class SpiderGL.WebGL.Buffer:
bind
destroy
setData
setSize
setSubData

Class Detail

SpiderGL.WebGL.IndexBuffer(gl, options)
Creates a SpiderGL.WebGL.IndexBuffer. SpiderGL.WebGL.IndexBuffer represents a wrapper for a WebGLBuffer to be bound to the WebGLRenderingContext.ELEMENT_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.VertexBuffer
SpiderGL.WebGL.ObjectGL

Field Detail

<static> {number} SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_COUNT
Default elements count when using SpiderGL.WebGL.IndexBuffer#drawElements. A negative value causes the calculation of the maximum number of elements given the buffer size, offset and index type.
Default Value:
-1
<static> {number} SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_MODE
Default elements draw mode when using SpiderGL.WebGL.IndexBuffer#drawElements.
Default Value:
WebGLRenderingContext.TRIANGLES
<static> {number} SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_OFFSET
Default index buffer offset when using SpiderGL.WebGL.IndexBuffer#drawElements.
Default Value:
0
<static> {number} SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_TYPE
Default index type when using SpiderGL.WebGL.IndexBuffer#drawElements.
Default Value:
WebGLRenderingContext.UNSIGNED_SHORT
<static> {number} SpiderGL.WebGL.IndexBuffer.TARGET
WebGL target for index buffers.
Default Value:
WebGLRenderingContext.ELEMENT_ARRAY_BUFFER

Method Detail

  • drawElements(options)
    Binds the index buffers and calls WebGLRenderingContext.drawElements with the provided parameters.
    var ib = new SpiderGL.WebGL.IndexBuffer(...); // create an index buffer
    // [... set ib data ...]
    // calling ib.drawElements has the same effect of:
    // ib.bind();
    // gl.drawElements(gl.TRIANGLES, (ib.size - offset) / SpiderGL.Type.SIZEOF_UINT16, gl.UNSIGNED_SHORT, offset);
    ib.drawElements({
    	glMode : gl.TRIANGLES,       // if omitted, defaults to SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_MODE
    	count  : 0,                  // if omitted, defaults to SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_COUNT
    	glType : gl.UNSIGNED_SHORT,  // if omitted, defaults to SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_TYPE
    	offset : offset              // if omitted, defaults to SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_OFFSET
    });
    Parameters:
    {object} options Optional
    Draw parameters.
    {number} options.glMode Optional, Default: SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_MODE
    The WebGL primitive type.
    {number} options.count Optional, Default: SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_COUNT
    Number of elements to draw. If less than or equal to zero, its value will be calculated as the maximum number of stored indices, based on offset, buffer size and index type.
    {number} options.glType Optional, Default: SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_TYPE
    Index type.
    {number} options.offset Optional, Default: SpiderGL.WebGL.IndexBuffer.DEFAULT_DRAW_ELEMENTS_OFFSET
    Offset (in bytes) from the start of the buffer.
  • <static> SpiderGL.WebGL.IndexBuffer.unbind(gl)
    WebGLBuffer unbinding for index buffers. This function binds the null buffer to the WebGLRenderingContext.ELEMENT_ARRAY_BUFFER target.
    Parameters:
    {WebGLRenderingContext} gl
    A WebGLRenderingContext.