IWebGLContext
- class genvidWebGL.IWebGLContext()
A useful wrapper over the WebGL context.
Properties
- genvidWebGL.IWebGLContext.clearColor
A 4D number array defining the color to use when clearing the WebGL context. The color sequence is [r, g, b, a], the values are floats between 0 and 1. Previous versions supported a vec4 object {x, y, z, w}. This format is now deprecated.
Type: [number,
number,
number,
number]
- 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:
void
- genvidWebGL.IWebGLContext.clear()
Erases both the color and depth of the WebGLContext.
- Returns:
void
- genvidWebGL.IWebGLContext.createBuffer(data)
Return the buffer, as well as the data length.
- Arguments:
data – any
- Returns:
[WebGLBuffer, number]
- genvidWebGL.IWebGLContext.createIndexBuffer(data)
Return the buffer, as well as the data length.
- Arguments:
data – any
- Returns:
[WebGLBuffer, number]
- genvidWebGL.IWebGLContext.createIndexBufferForQuads(numQuads)
Return the buffer, as well as the data length.
- Arguments:
numQuads – any
- Returns:
[WebGLBuffer, number]
- genvidWebGL.IWebGLContext.deleteBuffer(buffer)
Deletes a buffer.
- Arguments:
buffer – WebGLBuffer The buffer identifier.
- Returns:
void
- genvidWebGL.IWebGLContext.deleteProgram(program)
Deletes a shader program.
- Arguments:
program – WebGLProgram The program identifier.
- Returns:
void
- genvidWebGL.IWebGLContext.deleteShader(shader)
Deletes the specified shader.
- Arguments:
shader – WebGLShader The shader identifier.
- Returns:
void
- 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(vertexShader, fragmentShader, bindings)
Creates and links a new shader program with the specified vertex and fragment shaders, as well as an array of bindings.
- Arguments:
vertexShader – any The vertex shader identifier.
fragmentShader – any The fragment shader identifier.
bindings – any An array of bindings sent to bindAttribLocation().
- Returns:
WebGLProgram
- genvidWebGL.IWebGLContext.loadShader(type, source)
- Arguments:
type – number
source – string
- Returns:
WebGLShader
- genvidWebGL.IWebGLContext.loadVertexShader(source)
: any 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:
void