develop wherever and whenever you want...
Docs > WebGLContext Class Summary

WebGLContext Class Summary

WebGLContext objects are obtained by calling getContext() on a GLView object. This context can then be used to issue WebGL commands to render 3D content in Jasic. Jasic offers complete suport for WebGL and supports editing GLSL shaders in the source editor. The WebGLContext methods are listed by importance and typical usage.

Example shaderfs = " void main(void) {\n"; 
shader
fs += " glFragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"; 
shader
fs += " }\n";

var shadervs = " attribute vec4 vPosition;\n"; 
shader
vs += " void main() {\n"; 
shadervs += " glPosition = vPosition;\n"; 
shader_vs += " }";

var gl = null;

function getShader(t, s) { 
var shader = gl.createShader(t); 
gl.shaderSource(shader, s); 
gl.compileShader(shader); 
return shader; 
}

function main() { 
v = new View("ipad-portrait"); 
vgl = v.createGlView(0,0,500,500); 
gl = vgl.getContext();

gl.start();
gl.clearColor(0,0,0.9,1);
gl.clear(gl.COLOR_BUFFER_BIT);
var vertexShader = getShader(gl.VERTEX_SHADER, shader_vs);
var fragmentShader = getShader(gl.FRAGMENT_SHADER, shader_fs);
var shaderProgram = gl.createProgram();
gl.attachShader(shaderProgram, vertexShader);
gl.attachShader(shaderProgram, fragmentShader);
gl.bindAttribLocation(shaderProgram, 0, "vPosition");
gl.linkProgram(shaderProgram);
gl.useProgram(shaderProgram);
var buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
var vertices = [ 0.0, 0.5, 0.0, -0.5, -0.5, 0.0, 0.5, -0.5, 0.0 ];
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(0);
gl.drawArrays(gl.TRIANGLES, 0, 3);
gl.flush();
}

main(); 
document.wait(); 

void start() 
Begin rendering WebGL content. All other render related calls must be done between a start() and flush() or finish() call.

void flush() Render all WebGL content since issuing the start() command.

void finish() 
In Jasic, identical to flush().

void clearColor(red,green,blue,alpha) 
Set the color to use when clearing color. Each component is a floating point between 0 and 1.

void clear(mask) 
Clear the display based on mask value which can be: COLORBUFFERBIT, DEPTHBUFFERBIT, or STENCILBUFFERBIT. Multiple values can be or'd together.

object createShader(type) 
Create a shader based on type which can be VERTEXSHADER or FRAGMENTSHADER.

void shaderSource(shader,source) 
Set the GLSL source for a given shader.

void compileShader(shader) 
Compile the shader once source is set. To check for errors, use getShaderParameter().

object createProgram() 
Create a GLSL program which has a vertex shader and a fragment shader.

void attachShader(program,shader) 
Attach the shader to a program.

void bindAttribLocation(program,index,name) 
Associate a numeric index with an attribute name in a GLSL program.

void linkProgram(program) 
Link the program. To check for errors use getProgramParameter().

void useProgram(program) 
Make a given program the current program to use during rendering operations.

object createBuffer() 
Create a WebGL buffer object. Buffers are used to hold position, color, or other vertex related content.

void bindBuffer(target, buffer) 
Bind a buffer to a given target which can be ARRAYBUFFER or ELEMENTARRAYBUFFER. Once bound, other WebGL calls use the target to reference information about the buffer. This function is used to establish how bufferData() treats the content it is given. ELEMENTARRAYBUFFER typically receives data as indices to vertices which were established using an ARRAYBUFFER. So typically, the data is defined using a Uint16Array. ARRAY_BUFFER contains raw un-indexed data typically Float32Array content.

void bufferData(target,data,usage) 
Assign data to a given buffer by target (ARRAYBUFFER or ELEMENTARRAYBUFFER). The data is typically a typed array created using Float32Array or other typed arrays. usage can be STATICDRAW, DYNAMICDRAW, or STREAMDRAW. DYNAMIC_DRAW can be used to indicate that the underlying buffer data can change between render calls.

void vertexAttribPointer(index,size,type,normalize,stride,offset) 
index is the vertex attribute index assigned in bindAttribLocation, size is the number of values for each entry (for example for a vertex position, 3 entries are needed). type is the type of each value and can be FIXED, BYTE, SHORT, UNSIGNEDSHORT, UNSIGNEDBYTE, FLOAT. normalized (typically false), stride allows for padded array content (typically 0), and offset defines the starting offset to use within the buffer data.

void enableVertexAttribArray(index) 
Enable a vertex attribute array given index (from bindAttribLocation) for use in subsequent draw calls.

void drawArrays(mode,first,count) 
Draw arrays of data, mode can be TRIANGLES, TRIANGLESTRIP, TRIANGLEFAN, POINTS, LINES, LINELOOP, or LINESTRIP. first is the index of the first element to draw (typically 0) and count is the number of entries to draw for each element (for example for a triangle, 3 vertex positions are needed for each element in the array).

value getShaderParameter(shader,param) 
Returns information about a shader: param can be one of the following: SHADERTYPE, COMPILESTATUS, SHADERSOURCELENGTH, DELETESTATUS, INFOLOG_LENGTH.

string getShaderInfoLog(shader) 
Returns the text logging information for the shader. Typically used to display any errors encountered during shader compilation.

value getProgramParameter(program,param) 
Return infromation about a given program. param can be one of the following: LINKSTATUS, DELETESTATUS, VALIDATESTATUS, INFOLOGLENGTH, ATTACHEDSHADERS, ACTIVEUNIFORMS, ACTIVEATTRIBUTES, ACTIVEATTRIBUTEMAXLENGTH, ACTIVEUNIFORMMAXLENGTH.

number getAttribLocation(program,attrib) 
Get the unique index for a an attribute in a program given the attribute name (attrib). This is typically used in functions like enableVertexAttribArray() instead of using bindAttribLocation().

number getUniformLocation(program,uniform) 
Get the unique index for a an attribute in a program given the uniform name. This is typically used in functions like uniformMatrix4fv() to assign data to a uniform.

void uniformMatrix4fv(location,transpose,data) 
Set the value to a uniform (location is the index returned from getUniformLocation) to data as a Float32Array(16) value. transpose indicates whether the matrix is column major and should be transposed.

void viewport(x,y,width,height) 
Set the WebGL viewport to the coordinates supplied. This established normalized device coordinates such that 1.0 is equal to width horizontally and 1.0 is equal to height vertically.

void drawElements(mode,count,type,offset) 
Draw indexed elements using the current ELEMENTARRAYBUFFER. mode can be TRIANGLES, TRIANGLESTRIP, TRIANGLEFAN, POINTS, LINES, LINELOOP, or LINESTRIP. count is the number of indices in the buffer, type can be UNSIGNEDSHORT or UNSIGNEDBYTE, offset is the index of the first element to render.

void enable(state) 
Enable one of the following state variables. state can be one of the following: DEPTHTEST, BLEND, STENCILTEST, CULLFACE, POLYGONOFFSETFILL, FILLSAMPLEALPHATOCOVERAGE, or SAMPLECOVERAGE.

void disable(state) 
Disable one of the following state variables. state can be one of the following: DEPTHTEST, BLEND, STENCILTEST, CULLFACE, POLYGONOFFSETFILL, FILLSAMPLEALPHATOCOVERAGE, or SAMPLECOVERAGE.

object createTexture() 
Create an uninitialized texture object.

object TextureImage(file) 
This is not a method on the WebGLContext object, rather a constructor function used to create images which can be used as textures.

void bindTexture(target,texture) 
Makes a given texture object the current target. target can be one of TEXTURE2D or TEXTURECUBE_MAP. use null to unbind the current texture.

void pixelStorei(param,value) 
Control pixel storage options for texture objects. param can be one of the following: UNPACKFLIPYWEBGL (flip image vertically), UNPACKALIGNMENT, PACKALIGNMENT, PREMULTIPLYALPHAWEBGL, or UNPACKCOLORCONVERSION_WEBGL. value is a boolean which can be true or false.

void texImage2D(target,level,internalFormat,format,type,image) Bind an image to a texture. target is the texture target which can be: TEXTURE2D or TEXTURECUBEMAPPOSITIVEX, TEXTURECUBEMAPPOSITIVEY, TEXTURECUBEMAPPOSITIVEZ, TEXTURECUBEMAPNEGATIVEX, TEXTURECUBEMAPNEGATIVEY, or TEXTURECUBEMAPNEGATIVEZ. level is the mip level to bind to. internalFormat is the number of color components (1,2,3,or 4) or one of the following: ALPHA, LUMINANCE, LUMINANCEALPHA, RGB, or RGBA. format is the image format to use which can be one of the following: RGB, RGBA, ALPHA, LUMINANCE, or LUMINANCEALPHA. type can be one of the following: UNSIGNEDBYTE, UNSIGNEDSHORT565, UNSIGNEDSHORT4444, or UNSIGNEDSHORT5551. image is the object created using the TextureImage() constructor.

void texImage2D(target,level,internal,width,height,border,format,type,image) 
Bind an image to a texture. target is the texture target which can be: TEXTURE2D or TEXTURECUBEMAPPOSITIVEX, TEXTURECUBEMAPPOSITIVEY, TEXTURECUBEMAPPOSITIVEZ, TEXTURECUBEMAPNEGATIVEX, TEXTURECUBEMAPNEGATIVEY, or TEXTURECUBEMAPNEGATIVEZ. level is the mip level to bind to. internal is the number of color components (1,2,3,or 4) or one of the following: ALPHA, LUMINANCE, LUMINANCEALPHA, RGB, or RGBA. width and height define the dimensions of the texture. border controls whether a border is added or not (0 or 1). format is the image format to use which can be one of the following: RGB, RGBA, ALPHA, LUMINANCE, or LUMINANCEALPHA. type can be one of the following: UNSIGNEDBYTE, UNSIGNEDSHORT565, UNSIGNEDSHORT4444, or UNSIGNEDSHORT5551. image is the object created using the TextureImage() constructor.

void texParameteri(target,param,value) 
Controls the tiling or wrapping of the texture on a surface as well as texture filters. target can be TEXTURE2D or TEXTURECUBEMAP. pname can be one of the following: TEXTUREWRAPS, TEXTUREWRAPT, TEXTUREMINFILTER, TEXTUREMAGFILTER. For filter value can be NEAREST, LINEARMIPMAP_NEAREST, or LINEAR.

void activeTexture(unit) 
Downloads the current texture set with bindTexture() to a given texture unit on the GPU. unit can be TEXTURE0, TEXTURE1, ... etc.

void uniform1i(location,value) 
Set the value to a uniform (location is the index returned from getUniformLocation) to an integer value.

void uniform2i(location,i1,i2) 
Set the value to a uniform (location is the index returned from getUniformLocation) to two integer values.

void uniform3i(location,i1,i2,i3) 
Set the value to a uniform (location is the index returned from getUniformLocation) to three integer values.

void uniform4i(location,i1,i2,i3,i4) 
Set the value to a uniform (location is the index returned from getUniformLocation) to four integer values.

void generateMipmap(target) 
Generate level of detail mipmap textures for a given target: TEXTURE2D or TEXTURECUBE_MAP.

void uniformMatrix2fv(location,transpose,data) 
Set the value to a uniform (location is the index returned from getUniformLocation) to data as a Float32Array(4) 2x2 matrix value. transpose indicates whether the matrix is column major and should be transposed.

void uniformMatrix3fv(location,transpose,data) 
Set the value to a uniform (location is the index returned from getUniformLocation) to data as a Float32Array(9) 3x3 matrix value. transpose indicates whether the matrix is column major and should be transposed.

void uniformMatrix4fv(location,transpose,data) 
Set the value to a uniform (location is the index returned from getUniformLocation) to data as a Float32Array(16) 4x4 matrix value. transpose indicates whether the matrix is column major and should be transposed.

void uniform1f(location,value) 
Set the value to a uniform (location is the index returned from getUniformLocation) to a floating point value.

void uniform2f(location,f1,f2) 
Set the value to a uniform (location is the index returned from getUniformLocation) to two floating point values.

void uniform3f(location,f1,f2,f3) 
Set the value to a uniform (location is the index returned from getUniformLocation) to 3 floating point values f1, f2, and f3.

void uniform4f(location,f1,f2,f3,f4) 
Set the value to a uniform (location is the index returned from getUniformLocation) to four floating point values.

void uniform1iv(location,array) 
Set the value to a uniform (location is the index returned from getUniformLocation) to a single floating point value created using Uint32Array.

void uniform2iv(location,array) 
Set the value to a uniform (location is the index returned from getUniformLocation) to two floating point values created using Uint32Array.

void uniform3iv(location,array) 
Set the value to a uniform (location is the index returned from getUniformLocation) to three floating point values created using Uint32Array.

void uniform4iv(location,array) 
Set the value to a uniform (location is the index returned from getUniformLocation) to four floating point values created using Uint32Array.

void uniform1fv(location,array) 
Set the value to a uniform (location is the index returned from getUniformLocation) to a floating point value created using a Float32Array.

void uniform2fv(location,array) 
Set the value to a uniform (location is the index returned from getUniformLocation) to two floating point values created using a Float32Array.

void uniform3fv(location,value) 
Set the value to a uniform (location is the index returned from getUniformLocation) to 3 floating point values in using a Float32Array(3).

void uniform4fv(location,array) 
Set the value to a uniform (location is the index returned from getUniformLocation) to four floating point values created using a Float32Array.

void blendFunc(sfunc,dfunc) 
Controls source and destination blend functions. sfunc and dfunc values can be one of the following: ZERO, ONE, SRCCOLOR, ONEMINUSSRCCOLOR, DSTCOLOR, ONEMINUSDSTCOLOR, SRCALPHA, DSTALPHA, ONEMINUSSRCALPHA, ONEMINUSDSTALPHA, CONSTANTCOLOR, ONEMINUSCONSTANTCOLOR, CONSTANTALPHA, or ONEMINUSCONSTANTALPHA. In addition, sfunc can have the value SRCALPHASATURATE.

object createFramebuffer() 
Create a framebuffer object. Framebuffer objects are used to render content to a texture / offscreen.

void bindFramebuffer(target,buffer) 
Make the buffer object the current framebuffer. If null is passed, the original (screen) framebuffer is restored as the current framebuffer. The only supported target for bindFramebuffer is FRAMEBUFFER.

object createRenderbuffer() 
Create a renderbuffer object that can be assigned to a framebuffer object to render offscreen.

void bindRenderbuffer(target,buffer) 
Make the buffer object the current renderbuffer. If null is passed, the original (screen) renderbuffer is restored as the current framebuffer. The only supported target for bindRenderbuffer is RENDERBUFFER.

void renderbufferStorage(target,format,width,height) 
Control renderbuffer storage options. target must be RENDERBUFFER. format can be one of the following: DEPTHCOMPONENT16, STENCILINDEX8, RGBA4, RGB565, or RGB5_A1. width and height control the dimensions of the render buffer to use.

void framebufferTexture2D(target,attach,textarget,texture,level) 
Attach a texture to a framebuffer. All rendering to the framebuffer affects the texture pixels. target must be FRAMEBUFFER, attach defines the attachment association of the texture to the framebuffer and one of: COLORATTACHMENT0, DEPTHATTACHMENT, or STENCILATTACHMENT. textarget defines the associated texture to use and can be TEXTURE2D, TEXTURECUBEMAPPOSITIVEX, TEXTURECUBEMAPPOSITIVEY, TEXTURECUBEMAPPOSITIVEZ, TEXTURECUBEMAPNEGATIVEX, TEXTURECUBEMAPNEGATIVEY, or TEXTURECUBEMAPNEGATIVEZ. texture is the texture object to use. level is the mip level of the texture.

void framebufferRenderbuffer(target,attach,rbtarget,renderbuff) 
Attach a renderbuffer to a framebuffer. target must be FRAMEBUFFER, attach defines the attachment association of the texture to the framebuffer and one of: COLORATTACHMENT0, DEPTHATTACHMENT, or STENCIL_ATTACHMENT. rbtarget defines the associated renderbuffer to use and must be RENDERBUFFER. renderbuffer is the renderbuffer object to use.

void deleteBuffer(buffer) 
Delete a buffer obtained from a createBuffer() call.

boolean isBuffer(buffer) 
Returns true if the buffer object is a WebGL buffer.

void deleteRenderbuffer(buffer) 
Delete a renderbuffer obtained from a createRenderbuffer() call.

boolean isRenderbuffer(buffer) 
Returns true if the buffer object is a WebGL renderbuffer.

void deleteFramebuffer(buffer) 
Delete a framebuffer obtained from a createFramebuffer() call.

boolean isFramebuffer(buffer) 
Returns true if the buffer object is a WebGL framebuffer.

number checkFramebufferStatus(target) 
Check the current status of a framebuffer. target must be FRAMEBUFFER and the framebuffer object must be set using bindFramebuffer. Return value is one of the following: FRAMEBUFFERCOMPLETE, FRAMEBUFFERINCOMPLETEATTACHMENT, FRAMEBUFFERINCOMPLETEMISSINGATTACHMENT, FRAMEBUFFERINCOMPLETEDIMENSIONS, or FRAMEBUFFER_UNSUPPORTED

void detachShader(program,shader) 
Detach a given shader object from a program object.

void deleteShader(shader) 
Delete a shader object.

string getShaderSource(shader) 
Return the text source code of a shader object.

boolean isShader(shader) 
Returns true if a given object is a GLSL shader.

value getRenderbufferParameter(target,param) 
Return information about the current renderbuffer. target must be RENDERBUFFER. param can be one of the following: RENDERBUFFERWIDTH, RENDERBUFFERHEIGHT, RENDERBUFFERINTERNALFORMAT, RENDERBUFFERREDSIZE, RENDERBUFFERGREENSIZE, RENDERBUFFERBLUESIZE, RENDERBUFFERALPHASIZE, RENDERBUFFERDEPTHSIZE, RENDERBUFFERSTENCILSIZE

void deleteProgram(program) 
Delete a program object.

boolean isProgram(program) 
Returns true if argument is a program object.

string getProgramInfoLog(program) 
Return string infromation associated with linking or validating a program object.

void validateProgram(program) 
Validate a program object.

value getBufferParameter(target,param) 
Get information about a buffer. buffer can be ARRAYBUFFER or ELEMENTARRAYBUFFER. param can be BUFFERSIZE or BUFFER_USAGE.

void bufferSubData(target,offset,data) 
Update data in an exicting buffer. target (ARRAYBUFFER or ELEMENTARRAY_BUFFER). The data is typically a typed array created using Float32Array or other typed arrays. The offset is the data offset to start copying from.

value getParameter(param) 
Get value for various WebGL state parameters. param can be one of the following: ARRAYBUFFERBINDING, ELEMENTARRAYBUFFERBINDING, RENDERBUFFERBINDING, MAXRENDERBUFFERSIZE, REDBITS GREENBITS, BLUEBITS ALPHABITS, FRAMEBUFFERBINDING, STENCILTEST STENCILCLEARVALUE, STENCILFUNC STENCILFAIL, STENCILREF STENCILVALUEMASK, STENCILWRITEMASK STENCILBACKFUNC, STENCILBACKFAIL STENCILBACKREF, STENCILBITS STENCILBACKWRITEMASK, STENCILBACKVALUEMASK, STENCILBACKPASSDEPTHFAIL, STENCILBACKPASSDEPTHPASS, STENCILPASSDEPTHFAIL, STENCILPASSDEPTHPASS, CURRENTPROGRAM, SHADERCOMPILER MAXVARYINGVECTORS, TEXTUREBINDING2D, TEXTUREBINDINGCUBEMAP, MAXTEXTURESIZE, MAXCUBEMAPTEXTURESIZE, ACTIVETEXTURE, MAXTEXTUREIMAGEUNITS, MAXVERTEXTEXTUREIMAGEUNITS, MAXCOMBINEDTEXTUREIMAGEUNITS, BLEND BLENDCOLOR, BLENDDSTRGB, BLENDSRCRGB, BLENDDSTALPHA BLENDSRCALPHA, BLENDEQUATIONRGB, BLENDEQUATIONALPHA, SAMPLECOVERAGEVALUE, SAMPLECOVERAGEINVERT, SAMPLEBUFFERS, SAMPLES, MAXVERTEXATTRIBS, DEPTHTEST DEPTHRANGE, DEPTHWRITEMASK DEPTHCLEARVALUE, DEPTHFUNC DEPTHBITS, POLYGONOFFSETUNITS, POLYGONOFFSETFACTOR, MAXVERTEXUNIFORMVECTORS,, MAXFRAGMENTUNIFORMVECTORS, VIEWPORT, MAXVIEWPORTDIMS, COLORCLEARVALUE, SCISSORBOX, LINEWIDTH, ALIASEDPOINTSIZERANGE, ALIASEDLINEWIDTHRANGE, COLORWRITEMASK, SUBPIXELBITS, CULLFACEMODE, or FRONT_FACE

value getVertexAttrib(index,name) 
Return the value of an attribute given integer index and query name which can be one of the following: CURRENTVERTEXATTRIB, VERTEXATTRIBARRAYBUFFERBINDING, VERTEXATTRIBARRAYENABLED, VERTEXATTRIBARRAYSIZE, VERTEXATTRIBARRAYSTRIDE, VERTEXATTRIBARRAYTYPE, or VERTEXATTRIBARRAY_NORMALIZED.

value getFramebufferAttachmentParemeter(target,attach,param) 
Get a given attachment to the framebuffer. target must be FRAMEBUFFER. attach can be one of the following: FRAMEBUFFERATTACHMENTOBJECTTYPE, FRAMEBUFFERATTACHMENTOBJECTNAME, FRAMEBUFFERATTACHMENTTEXTURELEVEL, or FRAMEBUFFERATTACHMENTTEXTURECUBEMAPFACE

array readPixels(x,y,width,height,format,type) 
Read pixels from the current framebuffer and return the pixel color values in an array. x,y,width,height control the area to read from. format can be one of the following: RGBA, RGB, or ALPHA. type can be one of the following: UNSIGNEDBYTE, UNSIGNEDSHORT4444, UNSIGNEDSHORT5551, or UNSIGNEDSHORT565. Each component of the color is returned in an element of the array. So reading a single pixel (width == height == 1) with a format of RGBA and type of UNSIGNEDBYTE will return an array containing 4 values, one for red, green, blue, and alpha.

array getAttachedShaders(program) 
Return an array of all attached shader objects to the program.

void vertexAttrib1f(location,f1) 
Set vertex attribute value to a single floating point value.

void vertexAttrib2f(location,f1,f2) 
Set vertex attribute value to two floating point values.

void vertexAttrib3f(location,f1,f2,f3) 
Set vertex attribute value to three floating point values.

void vertexAttrib4f(location,f1,f2,f3,f4) 
Set vertex attribute value to four floating point values.

void vertexAttrib1fv(location,array) 
Set vertex attribute value to a single floating point value given array.

void vertexAttrib2fv(location,array) 
Set vertex attribute value to two floating point values given array.

void vertexAttrib3fv(location,array) 
Set vertex attribute value to three floating point values given array.

void vertexAttrib4fv(location,array) 
Set vertex attribute value to four floating point values given array.

void disableVertexAttribArray(index) 
Disable the vertex attribute array given an index. The index is from getAttribLocation or as specified by bindAttribLocation.

void cullFace(mode) 
Control face culling of polygons. mode can be: FRONT, BACK, or FRONTANDBACK.

void frontFace(mode) 
Control winding order of polygons. mode can be: CW or CCW.

void deleteTexture(texture) 
Delete texture object.

value getTexParameter(target,param) 
Get a parameter value for a texture. target can be TEXTURE2D or TEXTURECUBEMAP. param can be: TEXTUREWRAPS, TEXTUREWRAPT, TEXTUREMINFILTER, or TEXTUREMAG_FILTER.

void texParameterf(target,param,value) 
Set a parameter value for a texture using a floating point value. target can be TEXTURE2D or TEXTURECUBEMAP. param can be: TEXTUREWRAPS, TEXTUREWRAPT, TEXTUREMINFILTER, or TEXTUREMAG_FILTER.

void texParameteri(target,param,value) 
Set a parameter value for a texture using an integer value. target can be TEXTURE2D or TEXTURECUBEMAP. param can be: TEXTUREWRAPS, TEXTUREWRAPT, TEXTUREMINFILTER, or TEXTUREMAGFILTER. void texSubImage2D(target,level,x,y,width,height,format,type,data) Set a portion (x,y,width,height) of a texture image to an object (data) created using TextureImage() constructor. target must be TEXTURE2D or TEXTURECUBEMAPPOSITIVEX, TEXTURECUBEMAPPOSITIVEY, TEXTURECUBEMAPPOSITIVEZ, TEXTURECUBEMAPNEGATIVEX, TEXTURECUBEMAPNEGATIVEY, or TEXTURECUBEMAPNEGATIVEZ . level is the required mip level of the texture to use. format can be RGBA, RGB, ALPHA, LUMINANCE, or LUMINANCEALPHA. type can be UNSIGNEDBYTE, UNSIGNEDSHORT565, UNSIGNEDSHORT4444, or UNSIGNEDSHORT5551.

void texSubImage2D(target,level,x,y,format,type,data) 
Set a portion (offset x and y) of a texture image to an object (data) created using TextureImage() constructor. target must be TEXTURE2D or TEXTURECUBEMAPPOSITIVEX, TEXTURECUBEMAPPOSITIVEY, TEXTURECUBEMAPPOSITIVEZ, TEXTURECUBEMAPNEGATIVEX, TEXTURECUBEMAPNEGATIVEY, or TEXTURECUBEMAPNEGATIVEZ. level is the required mip level of the texture to use. format can be RGBA, RGB, ALPHA, LUMINANCE, or LUMINANCEALPHA. type can be UNSIGNEDBYTE, UNSIGNEDSHORT565, UNSIGNEDSHORT4444, or UNSIGNEDSHORT555_1.

void copyTexImage2D(target,level,format,x,y,width,height,border) 
Copy texture image data (offset x and y). target must be TEXTURE2D or TEXTURECUBEMAPPOSITIVEX, TEXTURECUBEMAPPOSITIVEY, TEXTURECUBEMAPPOSITIVEZ, TEXTURECUBEMAPNEGATIVEX, TEXTURECUBEMAPNEGATIVEY, or TEXTURECUBEMAPNEGATIVEZ. level is the required mip level of the texture to use. format can be RGBA, RGB, ALPHA, LUMINANCE, or LUMINANCEALPHA.

void copyTexSubImage2D(target,level,xoffset,yoffset,x,y,width,height) 
Copy texture image data (offset x and y). target must be TEXTURE2D or TEXTURECUBEMAPPOSITIVEX, TEXTURECUBEMAPPOSITIVEY, TEXTURECUBEMAPPOSITIVEZ, TEXTURECUBEMAPNEGATIVEX, TEXTURECUBEMAPNEGATIVEY, or TEXTURECUBEMAPNEGATIVEZ. level is the required mip level of the texture to use. format can be RGBA, RGB, ALPHA, LUMINANCE, or LUMINANCEALPHA.

boolean isTexture(texture) 
Returns true if object is a texture.

void blendFuncSeparate(srcRgb,dstRgb,srcAlpha,dstAlpha) 
Define blending arithmetic functions used for RGB color values and alpha seperately. Allowed values are: ZERO, ONE, SRCCOLOR, ONEMINUSSRCCOLOR, DSTCOLOR, ONEMINUSDSTCOLOR, SRCALPHA, DSTALPHA, ONEMINUSSRCALPHA, ONEMINUSDSTALPHA, CONSTANTCOLOR, ONEMINUSCONSTANTCOLOR, CONSTANTALPHA, or ONEMINUSCONSTANTALPHA. In addition, srcAlpha can have the value SRCALPHASATURATE.

void blendEquation(mode) 
Control blend equation to use. mode can be FUNCADD, FUNCSUBTRACT, or FUNCREVERSESUBTTRACT.

void blendEquationSeparate(modeRgb,modeAlpha) 
Control blend equation to use separately for color and alpha. mode can be FUNCADD, FUNCSUBTRACT, or FUNCREVERSESUBTTRACT.

void blendColor(red,green,blue,alpha) 
Control blend color value.

void blendFunc(func) 
Control blending function to use. func can be: NEVER, LESS, EQUAL, LEQUAL, GREATER, NOTEQUAL GEQUAL, or ALWAYS

void depthMask(flag) 
Enables or disables writing to the depth buffer.

void depthRange(near,far) 
Defines mapping between world and device coordinates for depth range.

void clearDepth(value) 
Set all content of depth buffer to value.

void polygonOffset(scale,units) 
Control scale and units used in depth mapping.

void stencilFunc(func,ref,mask) 
Control stencil function to use. func can be NEVER, LESS, EQUAL, LEQUAL, GREATER, NOTEQUAL GEQUAL, or ALWAYS.

void stencilFuncSeparate(face,func,ref,mask) 
Control stencil function to use for a given face. face can be FRONT, BACK, or FRONTANDBACK. func can be NEVER, LESS, EQUAL, LEQUAL, GREATER, NOTEQUAL GEQUAL, or ALWAYS.

void stencilMask(mask) 
Control front and back writing of individual bits to the stencil buffer.

void stencilMaskSeparate(face,mask) 
Control front and back writing of individual bits to the stencil buffer for a given face. face can be FRONT, BACK, or FRONTANDBACK.

void stencilOp(fail,zfail,zpass) 
Control stencil and depth pass or fail actions. fail / zfail / zpass can be one of the following: KEEP, ZERO, INCR, INCRWRAP, REPLACE, INVERT, DECR, or DECRWRAP.

void stencilOpSeparate(facefail,zfail,zpass) 
Control stencil and depth pass or fail actions for each face. face can be FRONT, BACK, or FRONTANDBACK. fail / zfail / zpass can be one of the following: KEEP, ZERO, INCR, INCRWRAP, REPLACE, INVERT, DECR, or DECRWRAP.

void clearStencil(value) 
Clear stencil buffer to a given value.

object getActiveUniform(program,index) 
Return an object representing information about a given active uniform in a program. The object has a size, type, and name properties.

object getUniform(program,index) 
Return an object representing information about a given uniform in a program. The object has a size, type, and name properties.

object getActiveAttrib(program,index) 
Return an object representing information about a given active uniform in a program. The object has a size, type, and name properties.

void sampleCoverage(value,invert) 
Specify multi-sample coverage values.

void lineWidth(width) 
Define the line draw width of line primitives.

void colorMask(red,green,blue,alpha) 
Enable writing of individual color or alpha channel during rendering. All parameters are booleans which control whether a given component is written or not.

void scissor(x,y,width,height) 
Specify scissor region for rendering. All pixels outside of the scissor box are discarded.

number getError() 
Return error condition from last WebGL call. returned number can be one of the following: NOERROR, INVALIDENUM, OUTOFMEMORY, INVALIDVALUE, INVALIDOPERATION, or INVALIDFRAMEBUFFEROPERATION.