IWebGLContext

class genvidWebGL.IWebGLContext()

A useful wrapper over the WebGL context.

Properties

genvidWebGL.IWebGLContext.clear_color

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

Type: math.IVec4()

genvidWebGL.IWebGLContext.div

Type: HTMLCanvasElement

genvidWebGL.IWebGLContext.gl

The raw WebGL context created for the canvas.

You can use any valid WebGL routine on that context.

Type: WebGLRenderingContext

Methods

genvidWebGL.IWebGLContext.checkGLError()

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

Returns:any
genvidWebGL.IWebGLContext.clear()

Erases both the color and depth of the WebGLContext.

Returns:any
genvidWebGL.IWebGLContext.createBuffer(data)

Return the buffer, as well as the data length.

Arguments:
  • data – any
Returns:

genvidWebGL.IWebGLContext.createIndexBuffer(data)

Return the buffer, as well as the data length.

Arguments:
  • data – any
Returns:

genvidWebGL.IWebGLContext.createIndexBufferForQuads(numQuads)

Return the buffer, as well as the data length.

Arguments:
  • numQuads – any
Returns:

genvidWebGL.IWebGLContext.deleteBuffer(buffer)

Deletes a buffer.

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

any

genvidWebGL.IWebGLContext.deleteProgram(program)

Deletes a shader program.

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

any

genvidWebGL.IWebGLContext.deleteShader(shader)

Deletes the specified shader.

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

any

genvidWebGL.IWebGLContext.loadFragmentShader(source)

Compiles the specified source string as a fragment shader.

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

WebGLShader

genvidWebGL.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

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

WebGLShader

genvidWebGL.IWebGLContext.loadVertexShader(source)

Compiles the specified source string as a vertex shader.

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

WebGLShader

genvidWebGL.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