JavaScripture
Contribute via GitHub Feedback

JavaScript WebGLRenderingContext : Object

The WebGLRenderingContext is an object that is used to issue WebGL rendering commands to a canvas. The WebGLRenderingContext is obtained by passing 'webgl' (many browsers use 'experimental-webgl' currently) to the HTMLCanvasElement.getContext() method. See WebGLContextAttributes for configuration options you can specify when calling getContext().

For detailed information on the shader language used by WebGL, see the GLSL Specification.

While developing with WebGL, you can use the debug context to easily find errors in your code. The samples below use the debug context to help catch errors but you should remove it in production code. See http://www.khronos.org/webgl/wiki/Debugging for more details.

Instance Properties

canvas : HTMLCanvasElement  

The canvas that owns this WebGL context.

Example:

Run

Results:

 

drawingBufferHeight : Number  

Returns the height of the owner canvas in pixels.

Example:

Run

Results:

 

drawingBufferWidth : Number  

Returns the width of the owner canvas in pixels.

Example:

Run

Results:

 

Instance Methods

activeTexture(unit : Number) : undefined

Set the texture unit subsequent texture operations apply to.

unit
must be one of TEXTURE0, TEXTURE1, to getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS) - 1.
The default value is TEXTURE0. A texture must be bound to the active texture unit using bindTexture().

attachShader(program : WebGLProgram, shader : WebGLShader) : undefined

Attaches shader to program. A program must have both a VERTEX_SHADER and FRAGMENT_SHADER before it can be used. shader can be attached before its souce has been set. See also detachShader().

Example:

Run

Results:

 

bindAttribLocation(program : WebGLProgram, location : Number, attributeName : String) : undefined

Associates a number (location) with an attribute (a shader input such as vertex position) in program. Other webgl functions (such as enableVertexAttribArray() or vertexAttribPointer()) deal with an attribute location number instead of the name used in the program and bindAttribLocation is used to choose the number used for that attribute. Locations are automatically assigned if you do not call bindAttribLocation so this method is only necessary if you wish to assign a specific location for an attribute. Use getAttribLocation() to retrieve the automatically assigned location. bindAttribLocation() must be called before calling linkProgram(program) and location must be an integer in the range 0 to getParameter(gl.MAX_VERTEX_ATTRIBS) - 1.

Example:

Run

Results:

 

bindBuffer(target : Number, buffer : WebGLBuffer) : undefined

Sets the current buffer for target to buffer. target must be either ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER. Use bufferData() to fill the bound buffer with data.

bindFramebuffer(target : Number, framebuffer : WebGLFramebuffer) : undefined

Sets the current framebuffer to framebuffer. target must be FRAMEBUFFER. See createFramebuffer() for an example of using bindFramebuffer().

bindRenderbuffer(target : Number, renderbuffer : WebGLRenderbuffer) : undefined

Sets the current renderbuffer to renderbuffer. target must be RENDERBUFFER.

bindTexture(target : Number, texture : WebGLTexture) : undefined

Sets the specified target and texture (created with createTexture) for the bound texture in the active texture unit (set through activeTexture() and bindTexture). target must be one of TEXTURE_2D or TEXTURE_CUBE_MAP

blendColor(red : Number, green : Number, blue : Number, alpha : Number) : undefined

Specifies the blend color used with blendFunc(). Each component must be in the range 0.0 to 1.0.

blendEquation(mode : Number) : undefined
blendEquationSeparate(modeRGB : Number, modeAlpha : Number) : undefined

Sets how the newly rendered pixel color and alpha (src) is combined with the existing framebuffer color and alpha (dst) before storing in the framebuffer.

modeRGB and modeAlpha
must be one of FUNC_ADD, FUNC_SUBTRACT, or FUNC_REVERSE_SUBTRACT.
If the mode is FUNC_ADD, the destination color will be src + dst. If the mode is FUNC_SUBTRACT, the destination color will be src - dst. If the mode is FUNC_REVERSE_SUBTRACT, the destination color will be dst - src. Both modeRGB and modeAlpha default to FUNC_ADD. Use getParameter(gl.BLEND_EQUATION_RGB) and getParameter(gl.BLEND_EQUATION_ALPHA) to get the current values. See blendFuncSeparate() for how src and dst are computed. Blending must be enabled with enable(BLEND).

blendFunc(srcFactor : Number, dstFactor : Number) : undefined
blendFuncSeparate(srcRGB : Number, dstRGB : Number, srcAlpha : Number, dstAlpha : Number) : undefined

Adjusts the newly rendered pixel color and alpha (src) and existing framebuffer color and alpha in the framebuffer (dst) before being combined using blendEquationSeparate().

srcRGB, dstRGB, srcAlpha, and dstAlpha
must be one of ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR, SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR, CONSTANT_ALPHA, ONE_MINUS_CONSTANT_ALPHA, or SRC_ALPHA_SATURATE
srcRGB and srcAlpha default to ONE. dstRGB and dstAlpha default to NONE.

For traditional alpha blending, use:
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ZERO).

For premultiplied alpha blending, use:
gl.blendFuncSeparate(gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ZERO).

Use getParameter(gl.BLEND_SRC_RGB), getParameter(gl.BLEND_DST_RGB), getParameter(gl.BLEND_SRC_ALPHA), and getParameter(gl.BLEND_DST_ALPHA) to get the current values.

bufferData 3 variants
bufferData(target : Number, data : ArrayBufferView, usage : Number) : undefined
bufferData(target : Number, data : ArrayBuffer, usage : Number) : undefined
bufferData(target : Number, size : Number, usage : Number) : undefined

Creates the storage for the currently bound buffer.

target
must be one of ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER.
size
the size in bytes of the buffer to allocate.
usage
must be one of STREAM_DRAW, STATIC_DRAW, or DYNAMIC_DRAW.

bufferSubData 2 variants
bufferSubData(target : Number, offset : Number, data : ArrayBufferView) : undefined
bufferSubData(target : Number, offset : Number, data : ArrayBuffer) : undefined
checkFramebufferStatus(target : Number) : Number
clear(mask : Number) : undefined

Clears the buffers specified by mask where mask is the bitwise OR (|) of one or more of the following values: COLOR_BUFFER_BIT, STENCIL_BUFFER_BIT, and DEPTH_BUFFER_BIT.

Example:

Run

Results:

 

clearColor(red : Number, green : Number, blue : Number, alpha : Number) : undefined

Specifies the color to fill the color buffer when clear() is called with the COLOR_BUFFER_BIT. The parameters are clamped to the range 0 to 1.

Example:

Run

Results:

 

clearDepth(depth : Number) : undefined

Specifies the value to fill the depth buffer when clear() is called with the DEPTH_BUFFER_BIT. depth is clamped to the range 0 (near) to 1 (far). Defaults to 1 if not specified.

Example:

Run

Results:

 

clearStencil(s : Number) : undefined

Specifies the value (integer) to fill the depth buffer when clear() is called with the STENCIL_BUFFER_BIT.

Example:

Run

Results:

 

colorMask(red : Boolean, green : Boolean, blue : Boolean, alpha : Boolean) : undefined

Turns on or off writing to the specified channels of the frame buffer. Defaults to true for all channels. Use getParameter(gl.COLOR_WRITEMASK) to get the current value.

compileShader(shader : WebGLShader) : undefined

Compiles the specified shader. Must be called after setting the source with shaderSource(). If the shader had errors during compilation, gl.getShaderParameter(shader, gl.COMPILE_STATUS) will return false and you can use getShaderInfoLog() to get details about the error.

copyTexImage2D(target : Number, level : Number, internalformat : Number, x : Number, y : Number, width : Number, height : Number, border : Number) : undefined

Copies pixels from the framebuffer to the bound texture in the active texture unit (set through activeTexture() and bindTexture).

target
must be one of TEXTURE_2D, TEXTURE_CUBE_MAP_POSITIVE_X, TEXTURE_CUBE_MAP_NEGATIVE_X, TEXTURE_CUBE_MAP_POSITIVE_Y, TEXTURE_CUBE_MAP_NEGATIVE_Y, TEXTURE_CUBE_MAP_POSITIVE_Z, or TEXTURE_CUBE_MAP_NEGATIVE_Z.
level
specifies the mipmap level to copy into.
internalformat
ALPHA, LUMINANCE, LUMINANCE_ALPHA, RGB, or RGBA.
x, y, width, height
the rectangle in framebuffer to copy.
border
must be 0.

copyTexSubImage2D(target : Number, level : Number, textureX : Number, textureY : Number, framebufferX : Number, framebufferY : Number, width : Number, height : Number) : undefined

Copies pixels from the framebuffer to a subregion of the bound texture in the active texture unit (set through activeTexture() and bindTexture).

target
must be one of TEXTURE_2D, TEXTURE_CUBE_MAP_POSITIVE_X, TEXTURE_CUBE_MAP_NEGATIVE_X, TEXTURE_CUBE_MAP_POSITIVE_Y, TEXTURE_CUBE_MAP_NEGATIVE_Y, TEXTURE_CUBE_MAP_POSITIVE_Z, or TEXTURE_CUBE_MAP_NEGATIVE_Z.
level
specifies the mipmap level to copy into.
textureX, textureY
the position in the texture to store the copied pixels.
framebufferX, framebufferY
the position in the framebuffer to read the pixels to copy.
width, height
the size of the region to copy.

createBuffer() : WebGLBuffer

Creates a buffer. A buffer is memory used to store data passed to the shader program through attributes. See also bindBuffer(), bufferData(), bufferSubData(), deleteBuffer(), isBuffer(), vertexAttribPointer() and enableVertexAttribArray().

Example:

Run

Results:

 

createFramebuffer() : WebGLFramebuffer

Creates a framebuffer that can be used for offscreen rendering. See also bindFramebuffer(), checkFramebufferStatus(), deleteFramebuffer(), framebufferRenderbuffer(), framebufferTexture2D(), getFramebufferAttachmentParameter(), and isFramebuffer().

Example:

Run

Results:

 

createProgram() : WebGLProgram

Creates a shader program. A shader program consists of a vertex shader and fragment shader. Use attachShader() to associate shaders with the program and linkProgram() to finalize the program. After linking, use useProgram() to select the program to use.

createRenderbuffer() : WebGLRenderbuffer

Creates a renderbuffer. A renderbuffer is an offscreen section of memory used to store the result of rendering, such as the color buffer, depth buffer, or stencil buffer. See also framebufferRenderbuffer(), renderbufferStorage().

Example:

Run

Results:

 

createShader(type : Number) : WebGLShader

Creates a vertex or fragment shader. type must be either VERTEX_SHADER or FRAGMENT_SHADER. Shaders must be compiled using compileShader() and then attached to a WebGLProgram using attachShader() before they can be used.

createTexture() : WebGLTexture

Creates a texture. Use activeTexture() to select a texture unit and then bindTexture() to bind a texture to that unit. See also copyTexImage2D(), copyTexSubImage2D(), deleteTexture(), framebufferTexture2D(), getTexParameter(), isTexture(), texImage2D(), texParameterf(), texParameteri(), and texSubImage2D().

Example:

Run

Results:

 

cullFace(mode : Number) : undefined

Sets which side of the triangle is culled (not drawn). mode must be one of BACK, FRONT, or FRONT_AND_BACK. Defaults to BACK. To turn on culling, you must call enable(CULL_FACE). To select which face is the front or back, use frontFace().

deleteBuffer(buffer : WebGLBuffer) : undefined

Deletes the specified buffer.

deleteFramebuffer(framebuffer : WebGLFramebuffer) : undefined

Deletes the specified framebuffer.

deleteProgram(program : WebGLProgram) : undefined

Deletes the specified program.

deleteRenderbuffer(renderbuffer : WebGLRenderbuffer) : undefined

Deletes the specified renderprogram.

deleteShader(shader : WebGLShader) : undefined

Deletes the specified shader.

deleteTexture(texture : WebGLTexture) : undefined

Deletes the specified texture.

depthFunc(func : Number) : undefined

Specifies what function used to compare the rendered depth with the existing depth in the framebuffer to determine if the pixel will be written to the framebuffer. func must be one of NEVER, LESS, EQUAL, LEQUAL, GREATER, NOTEQUAL, GEQUAL, or ALWAYS. Defaults to LESS. Depth test will only be used if enabled with enable(DEPTH_TEST).

depthMask(write : Boolean) : undefined

Turns on or off writing to the depth buffer. Defaults to true. Use getParameter(gl.DEPTH_WRITEMASK) to get the current value. Depth test will only be used if enabled with enable(DEPTH_TEST).

depthRange(zNear : Number, zFar : Number) : undefined

Sets how z values returned from the vertex shader are mapped to values to store in the depth buffer. This mapping is necessary because the vertex shader output z values will be clipped to the range -1 to 1 but the depth buffer stores depth values in the range 0 to 1.

zNear
specifies what the vertex shader's -1 maps to in the depth buffer.
zFar
specifies what the vertex shader's 1 maps to in the depth buffer.
By default, zNear is 0 and zFar is 1.

detachShader(program : WebGLProgram, shader : WebGLShader) : undefined

Detaches shader from program. shader must have been attached to program using attachShader().

disable(capability : Number) : undefined

Turns off a capability. See enable() for a list of capabilities.

disableVertexAttribArray(index : Number) : undefined
drawArrays(mode : Number, vertexOffset : Number, vertexCount : Number) : undefined

Draws primitives using the vertex buffer data (stored in the ARRAY_BUFFER buffer).

mode
must be one of POINTS, LINE_STRIP, LINE_LOOP, LINES, TRIANGLE_STRIP, TRIANGLE_FAN, or TRIANGLES.
vertexOffset
specifies the index of the first vertex to draw.
vertexCount
specifies the number of vertices to draw.
You must call enableVertexAttribArray() for each attribute in the vertex shader that uses the vertex data. See also drawElements().

Example:

Run

Results:

 

drawElements(mode : Number, indicesCount : Number, indicesNumberType : Number, indicesOffset : Number) : undefined

Draws primitives using the vertex buffer data (stored in the ARRAY_BUFFER buffer) and the index buffer data (stored in the ELEMENT_ARRAY_BUFFER buffer).

mode
must be one of POINTS, LINE_STRIP, LINE_LOOP, LINES, TRIANGLE_STRIP, TRIANGLE_FAN, or TRIANGLES.
indicesCount
specifies the number of number of indices to use.
indicesNumberType
must be one of UNSIGNED_BYTE or UNSIGNED_SHORT.
indicesOffset
specifies the index into the indices array of the first element to draw.
You must call enableVertexAttribArray() for each attribute in the vertex shader that uses the vertex data. See also drawArrays().

Example:

Run

Results:

 

enable(capability : Number) : undefined

Turns on a capability. capability must be one of the following:

BLEND
if enabled, will combine the color generated by the fragment shader with the existing color in the framebuffer using the method specified by blendFunc(). Most commonly used to enable alpha blending. Defaults to disabled.
CULL_FACE
if enabled, will cull (not draw) triangles based on which face is visible. See cullFace() and frontFace() to configure culling. Defaults to disabled.
DEPTH_TEST
if enabled, fragments will only be written to the framebuffer if they pass the depth function (set with gl.depthFunc()). See also depthMask(), and depthRange(). Most commonly used to draw closer objects on top of further away objects. Defaults to disabled.
DITHER
if enabled, the colors will be dithered when written to the color buffer. Defaults to enabled.
POLYGON_OFFSET_FILL
if enabled, the offset specified by polygonOffset will be added to the depth for the fragment when writing to the depth buffer. Most commonly used to draw decals on top of already drawn surfaces. Defaults to disabled.
SAMPLE_COVERAGE
Defaults to disabled.
SAMPLE_ALPHA_TO_COVERAGE
Defaults to disabled.
SCISSOR_TEST
if enabled, fragments outside the scissor rectangle (set with scissor() will not be drawn. Defaults to disabled.
STENCIL_TEST
if enabled, perform a stencil test on each fragment and update the stencil buffer. See also stencilFunc and stencilOp. Defaults to disabled.
Use disable() to turn off the capability.

enableVertexAttribArray(attributeLocation : Number) : undefined

Turns on passing data to the vertex shader from the vertex buffer for the specified attribute. Use getAttribLocation() to retrieve the location of an attribute by name.

finish() : undefined
flush() : undefined
framebufferRenderbuffer(target : Number, attachment : Number, renderbuffertarget : Number, renderbuffer : WebGLRenderbuffer) : undefined

Specifies the renderbuffer to use as destination of rendering for the current framebuffer (set with the most recent bindFramebuffer() call).

target
must be FRAMEBUFFER.
attachment
determines what is rendered into renderbuffer. Pass COLOR_ATTACHMENT0 for color data, DEPTH_ATTACHMENT for depth data, or STENCIL_ATTACHMENT for stencil data.
renderbuffertarget
must be RENDERBUFFER.
renderbuffer
the buffer to store the rendered output.

Example:

Run

Results:

 

framebufferTexture2D(target : Number, attachment : Number, textarget : Number, texture : WebGLTexture, level : Number) : undefined

Specifies the texture to use as destination of rendering for the current framebuffer (set with the most recent bindFramebuffer() call).

target
must be FRAMEBUFFER.
attachment
determines what is rendered into renderbuffer. Pass COLOR_ATTACHMENT0 for color data, DEPTH_ATTACHMENT for depth data, or STENCIL_ATTACHMENT for stencil data.
target
must be one of TEXTURE_2D, TEXTURE_CUBE_MAP_POSITIVE_X, TEXTURE_CUBE_MAP_NEGATIVE_X, TEXTURE_CUBE_MAP_POSITIVE_Y, TEXTURE_CUBE_MAP_NEGATIVE_Y, TEXTURE_CUBE_MAP_POSITIVE_Z, or TEXTURE_CUBE_MAP_NEGATIVE_Z.
texture
the texture to store the rendered output.
level
must be 0.

frontFace(mode : Number) : undefined

Determines which side of triangles is the front face. mode must be one of CW or CCW. To turn on culling, you must call enable(CULL_FACE). To select which face is culled, use cullFace().

generateMipmap(target : Number) : undefined

Generate the mipmap for the bound texture in the active texture unit (set through activeTexture() and bindTexture). A mipmap is a set of textures that are 1/2, 1/4, 1/8, etc of the original image. The mipmap allows higher quality rendering when drawing the texture at smaller sizes. target must be one of TEXTURE_2D or TEXTURE_CUBE_MAP. Note, you can only generate mipmaps for textures where the width and height are both powers of 2 (such as 128, 256, 512, etc).

getActiveAttrib(program : WebGLProgram, index : Number) : WebGLActiveInfo

Returns information about an attribute in program. program must be linked before calling getActiveAttrib(). index must be between 0 and gl.getProgramParameter(program, ACTIVE_ATTRIBUTES) - 1.

getActiveUniform(program : WebGLProgram, index : Number) : WebGLActiveInfo

Returns information about a uniform in program. program must be linked before calling getActiveUniform(). index must be between 0 and gl.getProgramParameter(program, ACTIVE_UNIFORMS) - 1.

getAttachedShaders(program : WebGLProgram) : Array<WebGLShader>
getAttribLocation(program : WebGLProgram, name : String) : Number
getBufferParameter(target : Number, parameter : Number) : Object

target
must be one of ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER.
parameter
must be one of BUFFER_SIZE or BUFFER_USAGE.

getContextAttributes() : WebGLContextAttributes

Returns the attributes used to construct this context. To modify these attributes, pass in the desired attributes to the first call to HTMLCanvasElement.getContext('webgl', attributes).

Example:

Run

Results:

 

getError() : Number

Returns the first error hit since the last time getError() was called. The returned value will be one of NO_ERROR, INVALID_ENUM, INVALID_VALUE, INVALID_OPERATION, INVALID_FRAMEBUFFER_OPERATION, or OUT_OF_MEMORY.

getExtension(name : String) : Object

Enables the specified extension and returns an object that contains any constants or functions provided by the extension. Call getSupportedExtensions() to get an array of valid extension names. If name is not in the Array returned by getSupportedExtensions(), getExtension() will return null.

Example:

Run

Results:

 

getFramebufferAttachmentParameter(target : Number, attachment : Number, parameter : Number) : Object

target
must be FRAMEBUFFER.
attachment
the render target to query. Must be one of COLOR_ATTACHMENT0 for color data, DEPTH_ATTACHMENT for depth data, or STENCIL_ATTACHMENT for stencil data.
parameter
the parameter to query. Must be one of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, or FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE.

getParameter(parameter : Number) : Object

parameter must be one of ACTIVE_TEXTURE, ALIASED_LINE_WIDTH_RANGE, ALIASED_POINT_SIZE_RANGE, ALPHA_BITS, ARRAY_BUFFER_BINDING, BLEND, BLEND_DST_ALPHA, BLEND_DST_RGB, BLEND_EQUATION_ALPHA, BLEND_EQUATION_RGB, BLEND_SRC_ALPHA, BLEND_SRC_RGB, BLUE_BITS, COLOR_CLEAR_VALUE, COLOR_WRITEMASK, COMPRESSED_TEXTURE_FORMATS, CULL_FACE, CULL_FACE_MODE, CURRENT_PROGRAM, DEPTH_BITS, DEPTH_CLEAR_VALUE, DEPTH_FUNC, DEPTH_RANGE, DEPTH_TEST, DEPTH_WRITEMASK, DITHER, ELEMENT_ARRAY_BUFFER_BINDING, FRAMEBUFFER_BINDING, FRONT_FACE, GENERATE_MIPMAP_HINT, GREEN_BITS, LINE_WIDTH, MAX_COMBINED_TEXTURE_IMAGE_UNITS, MAX_CUBE_MAP_TEXTURE_SIZE, MAX_FRAGMENT_UNIFORM_VECTORS, MAX_RENDERBUFFER_SIZE, MAX_TEXTURE_IMAGE_UNITS, MAX_TEXTURE_SIZE, MAX_VARYING_VECTORS, MAX_VERTEX_ATTRIBS, MAX_VERTEX_TEXTURE_IMAGE_UNITS, MAX_VERTEX_UNIFORM_VECTORS, MAX_VIEWPORT_DIMS, NUM_COMPRESSED_TEXTURE_FORMATS, PACK_ALIGNMENT, POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_FILL, POLYGON_OFFSET_UNITS, RED_BITS, RENDERBUFFER_BINDING, RENDERER, SAMPLE_ALPHA_TO_COVERAGE, SAMPLE_BUFFERS, SAMPLE_COVERAGE, SAMPLE_COVERAGE_INVERT, SAMPLE_COVERAGE_VALUE, SAMPLES, SCISSOR_BOX, SCISSOR_TEST, SHADING_LANGUAGE_VERSION, STENCIL_BACK_FAIL, STENCIL_BACK_FUNC, STENCIL_BACK_PASS_DEPTH_FAIL, STENCIL_BACK_PASS_DEPTH_PASS, STENCIL_BACK_REF, STENCIL_BACK_VALUE_MASK, STENCIL_BACK_WRITEMASK, STENCIL_BITS, STENCIL_CLEAR_VALUE, STENCIL_FAIL, STENCIL_FUNC, STENCIL_PASS_DEPTH_FAIL, STENCIL_PASS_DEPTH_PASS, STENCIL_REF, STENCIL_TEST, STENCIL_VALUE_MASK, STENCIL_WRITEMASK, SUBPIXEL_BITS, TEXTURE_BINDING_2D, TEXTURE_BINDING_CUBE_MAP, UNPACK_ALIGNMENT, VIEWPORT, VENDOR, or VERSION.

Example:

Run

Results:

 

getProgramInfoLog(program : WebGLProgram) : String
getShaderInfoLog(shader : WebGLShader) : String
getShaderParameter(shader : WebGLShader, parameter : Number) : Object
getShaderPrecisionFormat(shadertype : Number, precisiontype : Number) : WebGLShaderPrecisionFormat

Returns information about the numerical precision limits of shader data types. target must be one of FRAGMENT_SHADER or VERTEX_SHADER. precisiontype must be one of LOW_FLOAT, MEDIUM_FLOAT, HIGH_FLOAT, LOW_INT, MEDIUM_INT, or HIGH_INT.

Example:

Run

Results:

 

getShaderSource(shader : WebGLShader) : String
getSupportedExtensions() : Array<String>

Returns an Array of Strings that indicate which extensions this canvas supports. See getExtension().

Example:

Run

Results:

 

getTexParameter(target : Number, parameter : Number) : Object

Returns the value of the specified parameter for the the bound texture in the active texture unit (set through activeTexture() and bindTexture). Use texParameterf() and texParameteri() to set texture parameters.

target
must be one of TEXTURE_2D or TEXTURE_CUBE_MAP.
parameter
must be one of TEXTURE_MAG_FILTER, TEXTURE_MIN_FILTER, TEXTURE_WRAP_S, or TEXTURE_WRAP_T.

getUniform(program : WebGLProgram, location : WebGLUniformLocation) : Object

Retrieves the value stored in location by a uniform*() call.

Example:

Run

Results:

 

getUniformLocation(program : WebGLProgram, name : String) : WebGLUniformLocation
getVertexAttribOffset(index : Number, parameter : Number) : Number

parameter must be VERTEX_ATTRIB_ARRAY_POINTER.

hint(target : Number, mode : Number) : undefined

target
must be GENERATE_MIPMAP_HINT.
mode
must be one of FASTEST, NICEST, or DONT_CARE.

isBuffer(buffer : WebGLBuffer) : Boolean

Returns true if buffer is a valid, bound buffer.

Example:

Run

Results:

 

isContextLost() : Boolean

isEnabled(capability : Number) : Boolean

Returns true if specified capability is enabled. See enable() for a list of capabilities.

isFramebuffer(framebuffer : WebGLFramebuffer) : Boolean

Returns true if framebuffer is a valid, bound framebuffer.

Example:

Run

Results:

 

isProgram(program : WebGLProgram) : Boolean

Returns true if program is a valid program.

Example:

Run

Results:

 

isRenderbuffer(renderbuffer : WebGLRenderbuffer) : Boolean

Returns true if renderbuffer is a valid, bound renderbuffer.

Example:

Run

Results:

 

isShader(shader : WebGLShader) : Boolean

Returns true if shader is a valid shader.

Example:

Run

Results:

 

isTexture(texture : WebGLTexture) : Boolean

Returns true if texture is a valid, bound texture.

Example:

Run

Results:

 

lineWidth(width : Number) : undefined
linkProgram(program : WebGLProgram) : undefined
pixelStorei(parameter : Number, value : Number) : undefined

Sets options that affect readPixels, texImage2D, texSubImage2D.

parameter Valid Values Initial Value
PACK_ALIGNMENT 1, 2, 4, or 8 4
UNPACK_ALIGNMENT 1, 2, 4, or 8 4
UNPACK_FLIP_Y_WEBGL true or false false
UNPACK_PREMULTIPLY_ALPHA_WEBGL true or false false
UNPACK_COLORSPACE_CONVERSION_WEBGL BROWSER_DEFAULT_WEBGL or NONE BROWSER_DEFAULT_WEBGL

polygonOffset(factor : Number, units : Number) : undefined
readPixels(x : Number, y : Number, width : Number, height : Number, format : Number, type : Number, data : ArrayBufferView) : undefined

Reads pixels from the framebuffer and copies them to data.

x, y, width, height
the region of the framebuffer to read.
format
must be one of ALPHA, RGB, or RGBA.
type
must be one of UNSIGNED_BYTE, UNSIGNED_SHORT_5_6_5, UNSIGNED_SHORT_4_4_4_4, or UNSIGNED_SHORT_5_5_5_1.
data
stores the read pixels
The read data is affected by the pixelStorei() options.

renderbufferStorage(target : Number, internalformat : Number, width : Number, height : Number) : undefined

Creates and initializes the backing storage for a renderbuffer.

target
must be RENDERBUFFER.
internalformat
must be one of RGBA4, RGB565, RGB5_A1, DEPTH_COMPONENT16, or STENCIL_INDEX8.
width, height
the size of the renderbuffer.
See also createRenderbuffer().

sampleCoverage(value : Number, invert : Boolean) : undefined
scissor(x : Number, y : Number, width : Number, height : Number) : undefined
shaderSource(shader : WebGLShader, source : String) : undefined
stencilFunc(function : Number, reference : Number, mask : Number) : undefined

Same as stencilFuncSeparate() with face set to FRONT_AND_BACK.

stencilFuncSeparate(face : Number, func : Number, ref : Number, mask : Number) : undefined

Sets the stencil function. To use stencil tests, you must set the WebGLContextAttributes.stencil parameter to true when calling getContext('webgl', contextAttributes) and enable with enable(STENCIL_TEST).

face
must be one of FRONT, BACK, or FRONT_AND_BACK
function
must be one of NEVER, LESS, LEQUAL, GREATER, GEQUAL, EQUAL, NOTEQUAL, or ALWAYS. Defaults to ALWAYS.
reference
The value to compare with the value in the stencil buffer. It is also the value that be written to the stencil buffer if stencilOp is set to REPLACE.
mask
A value bitwise ANDed with reference and the value in the stencil buffer before performing the stencil function.

stencilMask(mask : Number) : undefined
stencilMaskSeparate(face : Number, mask : Number) : undefined
stencilOp(fail : Number, zfail : Number, zpass : Number) : undefined
stencilOpSeparate(face : Number, fail : Number, zfail : Number, zpass : Number) : undefined
texImage2D 5 variants
texImage2D(target : Number, level : Number, internalformat : Number, format : Number, type : Number, canvas : HTMLCanvasElement) : undefined
texImage2D(target : Number, level : Number, internalformat : Number, format : Number, type : Number, data : ImageData) : undefined

Specifies the data for the bound texture in the active texture unit (set through activeTexture() and bindTexture).

target
must be one of TEXTURE_2D, TEXTURE_CUBE_MAP_POSITIVE_X, TEXTURE_CUBE_MAP_NEGATIVE_X, TEXTURE_CUBE_MAP_POSITIVE_Y, TEXTURE_CUBE_MAP_NEGATIVE_Y, TEXTURE_CUBE_MAP_POSITIVE_Z, or TEXTURE_CUBE_MAP_NEGATIVE_Z.
level
is the mipmap level (0 is base level).
internalformat
must be one of ALPHA, LUMINANCE, LUMINANCE_ALPHA, RGB, or RGBA.
format
must match internalformat.
type
must be one of UNSIGNED_BYTE, UNSIGNED_SHORT_5_6_5, UNSIGNED_SHORT_4_4_4_4, or UNSIGNED_5_5_5_1;
data
is the data to load into the texture.
The loaded data is affected by the pixelStorei() options. You can also use copyTexSubImage2D or texSubImage2D to initialize the texture.

Example:

Run

Results:

 

texImage2D(target : Number, level : Number, internalformat : Number, format : Number, type : Number, image : HTMLImageElement) : undefined

Example:

Run

Results:

 

texImage2D(target : Number, level : Number, internalformat : Number, format : Number, type : Number, video : HTMLVideoElement) : undefined
texImage2D(target : Number, level : Number, internalformat : Number, width : Number, height : Number, border : Number, format : Number, type : Number, data : ArrayBufferView) : undefined

Specifies the size and data of the bound texture in the active texture unit (set through activeTexture() and bindTexture).

target
must be one of TEXTURE_2D, TEXTURE_CUBE_MAP_POSITIVE_X, TEXTURE_CUBE_MAP_NEGATIVE_X, TEXTURE_CUBE_MAP_POSITIVE_Y, TEXTURE_CUBE_MAP_NEGATIVE_Y, TEXTURE_CUBE_MAP_POSITIVE_Z, or TEXTURE_CUBE_MAP_NEGATIVE_Z.
level
is the mipmap level (0 is base level).
internalformat
must be one of ALPHA, LUMINANCE, LUMINANCE_ALPHA, RGB, or RGBA.
width and height
are the size of the texture.
border
must be 0.
format
must match internalformat.
type
must be one of UNSIGNED_BYTE, UNSIGNED_SHORT_5_6_5, UNSIGNED_SHORT_4_4_4_4, or UNSIGNED_5_5_5_1;
data
is the data to load into the texture. May be null to allocate the texture without data.
The loaded data is affected by the pixelStorei() options. You can also use copyTexSubImage2D or texSubImage2D to initialize the texture.

Example:

Run

Results:

 

texParameterf(target : Number, parameter : Number, value : Number) : undefined
texParameteri(target : Number, parameter : Number, value : Number) : undefined

Sets the value of the specified parameter for the bound texture in the active texture unit (set through activeTexture() and bindTexture). Use getTexParameter() to get texture parameters.

parameter Valid Values Initial Value
TEXTURE_MIN_FILTER NEAREST, LINEAR, NEAREST_MIPMAP_NEAREST, LINEAR_MIPMAP_NEAREST, NEAREST_MIPMAP_LINEAR, or LINEAR_MIPMAP_LINEAR NEAREST_MIPMAP_LINEAR
TEXTURE_MAG_FILTER NEAREST or LINEAR LINEAR
TEXTURE_WRAP_S CLAMP_TO_EDGE, MIRRORED_REPEAT, or REPEAT REPEAT
TEXTURE_WRAP_T CLAMP_TO_EDGE, MIRRORED_REPEAT, or REPEAT REPEAT

texSubImage2D 5 variants
texSubImage2D(target : Number, level : Number, xoffset : Number, yoffset : Number, format : Number, type : Number, canvas : HTMLCanvasElement) : undefined
texSubImage2D(target : Number, level : Number, xoffset : Number, yoffset : Number, format : Number, type : Number, image : HTMLImageElement) : undefined
texSubImage2D(target : Number, level : Number, xoffset : Number, yoffset : Number, format : Number, type : Number, pixels : ImageData) : undefined
texSubImage2D(target : Number, level : Number, xoffset : Number, yoffset : Number, format : Number, type : Number, video : HTMLVideoElement) : undefined
texSubImage2D(target : Number, level : Number, xoffset : Number, yoffset : Number, width : Number, height : Number, format : Number, type : Number, pixels : ArrayBufferView) : undefined

The loaded data is affected by the pixelStorei() options.

uniform1f(uniformLocation : WebGLUniformLocation, x : Number) : undefined
uniform1fv 2 variants
uniform1fv(uniformLocation : WebGLUniformLocation, v : Array) : undefined
uniform1fv(uniformLocation : WebGLUniformLocation, v : Float32Array) : undefined
uniform1i(uniformLocation : WebGLUniformLocation, x : Number) : undefined
uniform1iv 2 variants
uniform1iv(uniformLocation : WebGLUniformLocation, v : Int32Array) : undefined
uniform1iv(uniformLocation : WebGLUniformLocation, v : Array) : undefined
uniform2f(uniformLocation : WebGLUniformLocation, x : Number, y : Number) : undefined
uniform2fv 2 variants
uniform2fv(uniformLocation : WebGLUniformLocation, v : Array) : undefined
uniform2fv(uniformLocation : WebGLUniformLocation, v : Float32Array) : undefined
uniform2i(uniformLocation : WebGLUniformLocation, x : Number, y : Number) : undefined
uniform2iv 2 variants
uniform2iv(uniformLocation : WebGLUniformLocation, v : Int32Array) : undefined
uniform2iv(uniformLocation : WebGLUniformLocation, v : Array) : undefined
uniform3f(uniformLocation : WebGLUniformLocation, x : Number, y : Number, z : Number) : undefined
uniform3fv 2 variants
uniform3fv(uniformLocation : WebGLUniformLocation, v : Array) : undefined
uniform3fv(uniformLocation : WebGLUniformLocation, v : Float32Array) : undefined
uniform3i(uniformLocation : WebGLUniformLocation, x : Number, y : Number, z : Number) : undefined
uniform3iv 2 variants
uniform3iv(uniformLocation : WebGLUniformLocation, v : Array) : undefined
uniform3iv(uniformLocation : WebGLUniformLocation, v : Int32Array) : undefined
uniform4f(uniforLocation : WebGLUniformLocation, x : Number, y : Number, z : Number, w : Number) : undefined
uniform4fv 2 variants
uniform4fv(uniformLocation : WebGLUniformLocation, v : Array) : undefined
uniform4fv(uniformLocation : WebGLUniformLocation, v : Float32Array) : undefined
uniform4i(uniformLocation : WebGLUniformLocation, x : Number, y : Number, z : Number, w : Number) : undefined
uniform4iv 2 variants
uniform4iv(uniformLocation : WebGLUniformLocation, v : Int32Array) : undefined
uniform4iv(uniformLocation : WebGLUniformLocation, v : Array) : undefined
uniformMatrix2fv 2 variants
uniformMatrix2fv(uniformLocation : WebGLUniformLocation, transpose : Boolean, value : Array) : undefined
uniformMatrix2fv(uniformLocation : WebGLUniformLocation, transpose : Boolean, value : Float32Array) : undefined
uniformMatrix3fv 2 variants
uniformMatrix3fv(uniformLocation : WebGLUniformLocation, transpose : Boolean, value : Array) : undefined
uniformMatrix3fv(uniformLocation : WebGLUniformLocation, transpose : Boolean, value : Float32Array) : undefined
uniformMatrix4fv 2 variants
uniformMatrix4fv(uniformLocation : WebGLUniformLocation, transpose : Boolean, value : Array) : undefined
uniformMatrix4fv(uniformLocation : WebGLUniformLocation, transpose : Boolean, value : Float32Array) : undefined
useProgram(program : WebGLProgram) : undefined
validateProgram(program : WebGLProgram) : undefined

Validates program is can be used (via useProgram()). If the program is valid gl.getProgramParameter(program, gl.VALIDATE_STATUS) will return true.

Example:

Run

Results:

 

vertexAttrib1f(attributeLocation : Number, x : Number) : undefined
vertexAttrib1fv 2 variants
vertexAttrib1fv(attribLocation : Number, values : Array) : undefined
vertexAttrib1fv(attribLocation : Number, values : Float32Array) : undefined
vertexAttrib2f(attribLocation : Number, x : Number, y : Number) : undefined
vertexAttrib2fv 2 variants
vertexAttrib2fv(attribLocation : Number, values : Array) : undefined
vertexAttrib2fv(attribLocation : Number, values : Float32Array) : undefined
vertexAttrib3f(attribLocation : Number, x : Number, y : Number, z : Number) : undefined
vertexAttrib3fv 2 variants
vertexAttrib3fv(attribLocation : Number, values : Array) : undefined
vertexAttrib3fv(attribLocation : Number, values : Float32Array) : undefined
vertexAttrib4f(attribLocation : Number, x : Number, y : Number, z : Number, w : Number) : undefined
vertexAttrib4fv 2 variants
vertexAttrib4fv(attribLocation : Number, values : Array) : undefined
vertexAttrib4fv(attribLocation : Number, values : Float32Array) : undefined
vertexAttribPointer(attribLocation : Number, size : Number, dataType : Number, normalized : Boolean, stride : Number, offset : Number) : undefined

Defines the data for the specified shader attribute.

attribLocation
is the location of the shader attribute. Use getAttribLocation() to get the location if you did not specify it explicitly with bindAttribLocation().
size
is the number of components for each attribute and must be 1, 2, 3, or 4.
dataType
must be one of BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, or FLOAT.
normalized
if true and dataType is not FLOAT, the data will be mapped to the range -1 to 1 for signed types and the range 0 to 1 for unsigned types.
stride
indicates the number of bytes between the consecutive attributes. If stride is 0, size * sizeof(dataType) will be used.
offset
is the number of bytes before the first attribute.

viewport(x : Number, y : Number, width : Number, height : Number) : undefined

WebGLRenderingContext Properties

ACTIVE_ATTRIBUTES : Number  

ACTIVE_ATTRIBUTE_MAX_LENGTH : Number  

ACTIVE_TEXTURE : Number  

Use getParameter(gl.ACTIVE_TEXTURE) to get the active texture unit set by the most recent activeTexture() call.

Example:

Run

Results:

 

ACTIVE_UNIFORMS : Number  

ACTIVE_UNIFORM_MAX_LENGTH : Number  

ALIASED_LINE_WIDTH_RANGE : Number  

ALIASED_POINT_SIZE_RANGE : Number  

ALPHA : Number  

ALPHA_BITS : Number  

ALWAYS : Number  

ARRAY_BUFFER : Number  

ARRAY_BUFFER_BINDING : Number  

ATTACHED_SHADERS : Number  

BACK : Number  

BLEND : Number  

BLEND_COLOR : Number  

BLEND_DST_ALPHA : Number  

BLEND_DST_RGB : Number  

BLEND_EQUATION : Number  

BLEND_EQUATION_ALPHA : Number  

BLEND_EQUATION_RGB : Number  

BLEND_SRC_ALPHA : Number  

BLEND_SRC_RGB : Number  

BLUE_BITS : Number  

BOOL : Number  

BOOL_VEC2 : Number  

BOOL_VEC3 : Number  

BOOL_VEC4 : Number  

BROWSER_DEFAULT_WEBGL : Number  

BUFFER_SIZE : Number  

BUFFER_USAGE : Number  

BYTE : Number  

CCW : Number  

CLAMP_TO_EDGE : Number  

COLOR_ATTACHMENT0 : Number  

COLOR_BUFFER_BIT : Number  

COLOR_CLEAR_VALUE : Number  

Use getParameter(gl.COLOR_CLEAR_VALUE) to get a Float32Array containing the current clear color set by the most recent clearColor() call.

Example:

Run

Results:

 

COLOR_WRITEMASK : Number  

Use getParameter(gl.COLOR_WRITEMASK) to get an Array of Boolean values indicating if render operations will write to the color channels of the framebuffer. Use colorMask() to change the values.

Example:

Run

Results:

 

COMPILE_STATUS : Number  

COMPRESSED_TEXTURE_FORMATS : Number  

CONSTANT_ALPHA : Number  

CONSTANT_COLOR : Number  

CONTEXT_LOST_WEBGL : Number  

CULL_FACE : Number  

CULL_FACE_MODE : Number  

CURRENT_PROGRAM : Number  

CURRENT_VERTEX_ATTRIB : Number  

CW : Number  

DECR : Number  

DECR_WRAP : Number  

DELETE_STATUS : Number  

DEPTH_ATTACHMENT : Number  

DEPTH_BITS : Number  

DEPTH_BUFFER_BIT : Number  

DEPTH_CLEAR_VALUE : Number  

DEPTH_COMPONENT : Number  

DEPTH_COMPONENT16 : Number  

DEPTH_FUNC : Number  

DEPTH_RANGE : Number  

DEPTH_STENCIL : Number  

DEPTH_STENCIL_ATTACHMENT : Number  

DEPTH_TEST : Number  

DEPTH_WRITEMASK : Number  

Use getParameter(gl.DEPTH_WRITEMASK) to get a Boolean value indicating if render operations will write to the depth buffer. Use depthMask() to change the value.

Example:

Run

Results:

 

DITHER : Number  

Example:

Run

Results:

 

DONT_CARE : Number  

DST_ALPHA : Number  

DST_COLOR : Number  

DYNAMIC_DRAW : Number  

ELEMENT_ARRAY_BUFFER : Number  

ELEMENT_ARRAY_BUFFER_BINDING : Number  

EQUAL : Number  

FASTEST : Number  

FLOAT : Number  

FLOAT_MAT2 : Number  

FLOAT_MAT3 : Number  

FLOAT_MAT4 : Number  

FLOAT_VEC2 : Number  

FLOAT_VEC3 : Number  

FLOAT_VEC4 : Number  

FRAGMENT_SHADER : Number  

Use gl.createShader(gl.FRAGMENT_SHADER) to create a fragment shader. Fragment shaders (also called pixel shaders) are functions that run for each pixel drawn by WebGL. They run after the vertex shader has transformed vertices from 3D space to 2D space. The fragment shader should set the built in gl_FragColor variable. For detailed information on the shader language used by WebGL, see the GLSL Specification.

FRAMEBUFFER : Number  

FRAMEBUFFER_ATTACHMENT_OBJECT_NAME : Number  

FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE : Number  

FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE : Number  

FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL : Number  

FRAMEBUFFER_BINDING : Number  

FRAMEBUFFER_COMPLETE : Number  

Returned by checkFramebufferStatus() to indicate that framebuffer is set up completely.

FRAMEBUFFER_INCOMPLETE_ATTACHMENT : Number  

Returned by checkFramebufferStatus() to indicate that there is an image attached to the framebuffer that cannot be rendered too. Possibilities include empty sized images or the image cannot be the target of color, depth, or stencil rendering. Color images must be of the formats RGBA4, RGB5_A1, or RGB565. Depth images must be of the format DEPTH_COMPONENT16. Stencil images must be of the format STENCIL_INDEX8.

FRAMEBUFFER_INCOMPLETE_DIMENSIONS : Number  

Returned by checkFramebufferStatus() to indicate that the images attached to the framebuffer have differing widths and heights.

FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : Number  

Returned by checkFramebufferStatus() to indicate that no images are attached to the framebuffer.

FRAMEBUFFER_UNSUPPORTED : Number  

Returned by checkFramebufferStatus() to indicate that the images attached to the framebuffer are not supported by the current implementation.

FRONT : Number  

FRONT_AND_BACK : Number  

FRONT_FACE : Number  

FUNC_ADD : Number  

FUNC_REVERSE_SUBTRACT : Number  

FUNC_SUBTRACT : Number  

GENERATE_MIPMAP_HINT : Number  

GEQUAL : Number  

GREATER : Number  

GREEN_BITS : Number  

HIGH_FLOAT : Number  

HIGH_INT : Number  

INCR : Number  

INCR_WRAP : Number  

INFO_LOG_LENGTH : Number  

INT : Number  

INT_VEC2 : Number  

INT_VEC3 : Number  

INT_VEC4 : Number  

INVALID_ENUM : Number  

INVALID_FRAMEBUFFER_OPERATION : Number  

INVALID_OPERATION : Number  

INVALID_VALUE : Number  

INVERT : Number  

KEEP : Number  

LEQUAL : Number  

LESS : Number  

LINEAR : Number  

LINEAR_MIPMAP_LINEAR : Number  

Note, you can only use LINEAR_MIPMAP_LINEAR for textures where the width and height are both powers of 2 (such as 128, 256, 512, etc).

LINEAR_MIPMAP_NEAREST : Number  

Note, you can only use LINEAR_MIPMAP_NEAREST for textures where the width and height are both powers of 2 (such as 128, 256, 512, etc).

LINES : Number  

LINE_LOOP : Number  

LINE_STRIP : Number  

LINE_WIDTH : Number  

LINK_STATUS : Number  

LOW_FLOAT : Number  

LOW_INT : Number  

LUMINANCE : Number  

LUMINANCE_ALPHA : Number  

MAX_COMBINED_TEXTURE_IMAGE_UNITS : Number  

Use getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS) to get the number of texture units available. See activeTexture().

Example:

Run

Results:

 

MAX_CUBE_MAP_TEXTURE_SIZE : Number  

Example:

Run

Results:

 

MAX_FRAGMENT_UNIFORM_VECTORS : Number  

Example:

Run

Results:

 

MAX_RENDERBUFFER_SIZE : Number  

Example:

Run

Results:

 

MAX_TEXTURE_IMAGE_UNITS : Number  

Example:

Run

Results:

 

MAX_TEXTURE_SIZE : Number  

Example:

Run

Results:

 

MAX_VARYING_VECTORS : Number  

The maximum number of varying vectors a program may define.

Example:

Run

Results:

 

MAX_VERTEX_ATTRIBS : Number  

The maximum number of attributes a vertex shader may define.

Example:

Run

Results:

 

MAX_VERTEX_TEXTURE_IMAGE_UNITS : Number  

Example:

Run

Results:

 

MAX_VERTEX_UNIFORM_VECTORS : Number  

The maximum number of uniforms a program may define.

Example:

Run

Results:

 

MAX_VIEWPORT_DIMS : Number  

Example:

Run

Results:

 

MEDIUM_FLOAT : Number  

MEDIUM_INT : Number  

MIRRORED_REPEAT : Number  

Note, you can only use MIRRORED_REPEAT for textures where the width and height are both powers of 2 (such as 128, 256, 512, etc).

NEAREST : Number  

NEAREST_MIPMAP_LINEAR : Number  

Note, you can only use NEAREST_MIPMAP_LINEAR for textures where the width and height are both powers of 2 (such as 128, 256, 512, etc).

NEAREST_MIPMAP_NEAREST : Number  

Note, you can only use NEAREST_MIPMAP_NEAREST for textures where the width and height are both powers of 2 (such as 128, 256, 512, etc).

NEVER : Number  

NICEST : Number  

NONE : Number  

NOTEQUAL : Number  

NO_ERROR : Number  

NUM_COMPRESSED_TEXTURE_FORMATS : Number  

ONE : Number  

ONE_MINUS_CONSTANT_ALPHA : Number  

ONE_MINUS_CONSTANT_COLOR : Number  

ONE_MINUS_DST_ALPHA : Number  

ONE_MINUS_DST_COLOR : Number  

ONE_MINUS_SRC_ALPHA : Number  

ONE_MINUS_SRC_COLOR : Number  

OUT_OF_MEMORY : Number  

PACK_ALIGNMENT : Number  

POINTS : Number  

POLYGON_OFFSET_FACTOR : Number  

POLYGON_OFFSET_FILL : Number  

POLYGON_OFFSET_UNITS : Number  

RED_BITS : Number  

RENDERBUFFER : Number  

RENDERBUFFER_ALPHA_SIZE : Number  

RENDERBUFFER_BINDING : Number  

RENDERBUFFER_BLUE_SIZE : Number  

RENDERBUFFER_DEPTH_SIZE : Number  

RENDERBUFFER_GREEN_SIZE : Number  

RENDERBUFFER_HEIGHT : Number  

RENDERBUFFER_INTERNAL_FORMAT : Number  

RENDERBUFFER_RED_SIZE : Number  

RENDERBUFFER_STENCIL_SIZE : Number  

RENDERBUFFER_WIDTH : Number  

RENDERER : Number  

REPEAT : Number  

Note, you can only use REPEAT for textures where the width and height are both powers of 2 (such as 128, 256, 512, etc).

REPLACE : Number  

RGB : Number  

RGB565 : Number  

RGB5_A1 : Number  

RGBA : Number  

RGBA4 : Number  

SAMPLER_2D : Number  

SAMPLER_CUBE : Number  

SAMPLES : Number  

SAMPLE_ALPHA_TO_COVERAGE : Number  

SAMPLE_BUFFERS : Number  

SAMPLE_COVERAGE : Number  

SAMPLE_COVERAGE_INVERT : Number  

SAMPLE_COVERAGE_VALUE : Number  

SCISSOR_BOX : Number  

SCISSOR_TEST : Number  

SHADER_SOURCE_LENGTH : Number  

SHADER_TYPE : Number  

SHADING_LANGUAGE_VERSION : Number  

SHORT : Number  

SRC_ALPHA : Number  

SRC_ALPHA_SATURATE : Number  

SRC_COLOR : Number  

STATIC_DRAW : Number  

STENCIL_ATTACHMENT : Number  

STENCIL_BACK_FAIL : Number  

STENCIL_BACK_FUNC : Number  

STENCIL_BACK_PASS_DEPTH_FAIL : Number  

STENCIL_BACK_PASS_DEPTH_PASS : Number  

STENCIL_BACK_REF : Number  

STENCIL_BACK_VALUE_MASK : Number  

STENCIL_BACK_WRITEMASK : Number  

STENCIL_BITS : Number  

STENCIL_BUFFER_BIT : Number  

STENCIL_CLEAR_VALUE : Number  

STENCIL_FAIL : Number  

STENCIL_FUNC : Number  

STENCIL_INDEX : Number  

STENCIL_INDEX8 : Number  

STENCIL_PASS_DEPTH_FAIL : Number  

STENCIL_PASS_DEPTH_PASS : Number  

STENCIL_REF : Number  

STENCIL_TEST : Number  

STENCIL_VALUE_MASK : Number  

STENCIL_WRITEMASK : Number  

STREAM_DRAW : Number  

SUBPIXEL_BITS : Number  

TEXTURE : Number  

TEXTURE0 : Number  

TEXTURE1 : Number  

TEXTURE10 : Number  

TEXTURE11 : Number  

TEXTURE12 : Number  

TEXTURE13 : Number  

TEXTURE14 : Number  

TEXTURE15 : Number  

TEXTURE16 : Number  

TEXTURE17 : Number  

TEXTURE18 : Number  

TEXTURE19 : Number  

TEXTURE2 : Number  

TEXTURE20 : Number  

TEXTURE21 : Number  

TEXTURE22 : Number  

TEXTURE23 : Number  

TEXTURE24 : Number  

TEXTURE25 : Number  

TEXTURE26 : Number  

TEXTURE27 : Number  

TEXTURE28 : Number  

TEXTURE29 : Number  

TEXTURE3 : Number  

TEXTURE30 : Number  

TEXTURE31 : Number  

TEXTURE4 : Number  

TEXTURE5 : Number  

TEXTURE6 : Number  

TEXTURE7 : Number  

TEXTURE8 : Number  

TEXTURE9 : Number  

TEXTURE_2D : Number  

TEXTURE_BINDING_2D : Number  

TEXTURE_BINDING_CUBE_MAP : Number  

TEXTURE_CUBE_MAP : Number  

TEXTURE_CUBE_MAP_NEGATIVE_X : Number  

TEXTURE_CUBE_MAP_NEGATIVE_Y : Number  

TEXTURE_CUBE_MAP_NEGATIVE_Z : Number  

TEXTURE_CUBE_MAP_POSITIVE_X : Number  

TEXTURE_CUBE_MAP_POSITIVE_Y : Number  

TEXTURE_CUBE_MAP_POSITIVE_Z : Number  

TEXTURE_MAG_FILTER : Number  

TEXTURE_MIN_FILTER : Number  

TEXTURE_WRAP_S : Number  

TEXTURE_WRAP_T : Number  

TRIANGLES : Number  

TRIANGLE_FAN : Number  

TRIANGLE_STRIP : Number  

UNPACK_ALIGNMENT : Number  

UNPACK_COLORSPACE_CONVERSION_WEBGL : Number  

UNPACK_FLIP_Y_WEBGL : Number  

UNPACK_PREMULTIPLY_ALPHA_WEBGL : Number  

UNSIGNED_BYTE : Number  

UNSIGNED_INT : Number  

UNSIGNED_SHORT : Number  

UNSIGNED_SHORT_4_4_4_4 : Number  

UNSIGNED_SHORT_5_5_5_1 : Number  

UNSIGNED_SHORT_5_6_5 : Number  

VALIDATE_STATUS : Number  

VENDOR : Number  

VERSION : Number  

VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : Number  

VERTEX_ATTRIB_ARRAY_ENABLED : Number  

VERTEX_ATTRIB_ARRAY_NORMALIZED : Number  

VERTEX_ATTRIB_ARRAY_POINTER : Number  

VERTEX_ATTRIB_ARRAY_SIZE : Number  

VERTEX_ATTRIB_ARRAY_STRIDE : Number  

VERTEX_ATTRIB_ARRAY_TYPE : Number  

VERTEX_SHADER : Number  

Use gl.createShader(gl.VERTEX_SHADER) to create a vertex shader. Vertex shaders are functions that run for each vertex and transform the vertex from 3D space to the 2D canvas space. They can also manipulate other attributes such as texture coordinates and normals which are then passed to the fragment shader. The vertex shader should set the built in gl_Position variable and may also set the gl_PointSize variable. For detailed information on the shader language used by WebGL, see the GLSL Specification.

VIEWPORT : Number  

ZERO : Number