Graphics functions to use with a WebGLRenderingContext.
Methods
-
(static) buildProgram(GL, shaders) → {WebGLProgram|null}
-
Creates, attaches given shaders, links, validates and returns a WebGLProgram object using the given context.
(writes link/validation errors to the console)Parameters:
Name Type Description GLWebGLRenderingContext the rendering context to use
shadersArray.<WebGLShader> the array of previously build WebGLShader objects to attach to the created program
Returns:
a program object or null on a link/validation error
- Type
- WebGLProgram | null
-
(static) buildShader(GL, shaderType, shaderSource) → {WebGLShader|null}
-
Creates, compiles and returns a WebGLShader object using the given context.
(writes compilation errors to the console)Parameters:
Name Type Description GLWebGLRenderingContext the rendering context to use
shaderTypeGLenum pass GL.VERTEX_SHADER or GL.FRAGMENT_SHADER
shaderSourceString the sourcecode for the shader in "OpenGL ES Shading Language" (the String must be in UTF-16 format)
Returns:
a shader object or null on a compilation error
- Type
- WebGLShader | null
-
(static) loadProgram(GL, shaderDescriptions, onLoadProgramFinished)
-
Asynchronously loads shader source files and afterwards compiles/links them as a new WebGLProgram object using the given context.
After success/failure it calls the function passed as the onLoadProgramFinished parameter.
(it is not safe to call this again before the callback started)
(writes any errors(loading/compiling/linking/validating) to the console)Parameters:
Name Type Description GLWebGLRenderingContext the rendering context to use
shaderDescriptionsArray.<String> each string expected as "type:sourceURL" where type is V for FRAGMENT_SHADER or F for VERTEX_SHADER and sourceURL is the URL for the file containing the shader source code in "OpenGL ES Shading Language"
onLoadProgramFinishedrlGL~onLoadProgramFinished a function to call after success or failure
Type Definitions
-
onLoadProgramFinished(glp)
-
Function signature for parameter
onLoadProgramFinished.Parameters:
Name Type Description glpWebGLProgram | null a WebGLProgram object on success, null if any error occured