IWebGLContext

class IWebGLContext()

A useful wrapper over the WebGL context.

Properties

IWebGLContext.clear_color: IVec4

A vec4() instance defining the color to use when clearing the WebGL context.

IWebGLContext.div: HTMLCanvasElement
IWebGLContext.gl: WebGLRenderingContext

The raw WebGL context created for the canvas.

You can use any valid WebGL routine on that context.

Methods

IWebGLContext.checkGLError()

Verifies the state of the WebGL context, and prints any error in both the JavaScript console, and in an alert box.

Returns:any
IWebGLContext.clear()

Erases both the color and depth of the WebGLContext.

Returns:any
IWebGLContext.createBuffer(data)

Return the buffer, as well as the data length.

Arguments:
  • data (any) –
Returns:

IWebGLContext.createIndexBuffer(data)

Return the buffer, as well as the data length.

Arguments:
  • data (any) –
Returns:

IWebGLContext.createIndexBufferForQuads(numQuads)

Return the buffer, as well as the data length.

Arguments:
  • numQuads (any) –
Returns:

IWebGLContext.deleteBuffer(buffer)

Deletes a buffer.

Arguments:
  • buffer (WebGLBuffer) – The buffer identifier.
Returns:

any

IWebGLContext.deleteProgram(program)

Deletes a shader program.

Arguments:
  • program (WebGLProgram) – The program identifier.
Returns:

any

IWebGLContext.deleteShader(shader)

Deletes the specified shader.

Arguments:
  • shader (WebGLShader) – The shader identifier.
Returns:

any

IWebGLContext.loadFragmentShader(source)

Compiles the specified source string as a fragment shader.

Arguments:
  • source (any) – The HLSL source code for the shader.
Returns:

WebGLShader

IWebGLContext.loadProgram(vertex_shader, fragment_shader, bindings)

Creates and links a new shader program with the specified vertex and fragment shaders, as well as an array of bindings.

Arguments:
  • vertex_shader (any) – The vertex shader identifier.
  • fragment_shader (any) – The fragment shader identifier.
  • bindings (any) – An array of bindings sent to bindAttribLocation().
Returns:

WebGLProgram

IWebGLContext.loadShader(type, source)
Arguments:
  • type (any) –
  • source (any) –
Returns:

WebGLShader

IWebGLContext.loadVertexShader(source)

Compiles the specified source string as a vertex shader.

Arguments:
  • source (any) – The HLSL source code for the shader.
Returns:

WebGLShader

IWebGLContext.setViewport(x, y, width, height)

Specifies the WebGL viewport rectangle.

Arguments:
  • x (number) – The left coordinate in the WebGL context.
  • y (number) – The bottom coordinate in the WebGL context.
  • width (number) – The horizontal resolution.
  • height (number) – The vertical resolution.
Returns:

any