IWebGLContext

class genvid.IWebGLContext()

A useful wrapper over the WebGL context.

Properties

genvid.IWebGLContext.clear_color

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

Type: genvidMath.IVec4()

genvid.IWebGLContext.div

Type: HTMLCanvasElement()

genvid.IWebGLContext.gl

The raw WebGL context created for the canvas.

You can use any valid WebGL routine on that context.

Type: WebGLRenderingContext()

Methods

genvid.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
genvid.IWebGLContext.clear()

Erases both the color and depth of the WebGLContext.

Returns:any
genvid.IWebGLContext.createBuffer(data)

Return the buffer, as well as the data length.

Arguments:
  • data (any) –
Returns:

genvid.IWebGLContext.createIndexBuffer(data)

Return the buffer, as well as the data length.

Arguments:
  • data (any) –
Returns:

genvid.IWebGLContext.createIndexBufferForQuads(numQuads)

Return the buffer, as well as the data length.

Arguments:
  • numQuads (any) –
Returns:

genvid.IWebGLContext.deleteBuffer(buffer)

Deletes a buffer.

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

any

genvid.IWebGLContext.deleteProgram(program)

Deletes a shader program.

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

any

genvid.IWebGLContext.deleteShader(shader)

Deletes the specified shader.

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

any

genvid.IWebGLContext.loadFragmentShader(source)

Compiles the specified source string as a fragment shader.

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

WebGLShader()

genvid.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()

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

WebGLShader()

genvid.IWebGLContext.loadVertexShader(source)

Compiles the specified source string as a vertex shader.

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

WebGLShader()

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