validateShader

View sourcevalidateShader(gl: WebGLRenderingContext, shader: WebGLShader, label?: string): boolean

Checks whether a compiled WebGL shader passed its compile-status check.

The helper reads gl.COMPILE_STATUS with WebGLRenderingContext#getShaderParameter. If the status is false, it logs the supplied label and the diagnostic returned by WebGLRenderingContext#getShaderInfoLog, then returns false. A successful check returns true without logging. Compilation failure is reported rather than thrown; this function does not compile the shader or alter its compilation state.

Examples

// `shader` was created and compiled with `createShader`.
if (!validateShader(gl, shader, 'vertex')) {
  return
}

Parameters

NameDescriptionDefault
gl

WebGL context that owns the shader.

—
shader

Compiled shader to inspect.

—
label?

Diagnostic label included in failure output.

''

Returns

true when COMPILE_STATUS is truthy; otherwise false.