Registry / web-framework / gl-format-compiler-error

gl-format-compiler-error

JSON →
library1.0.3jsnpmunverified

Formats WebGL GLSL compiler errors with code snippets and shader type context. Current stable version 1.0.3, no active release cadence (last updated 2015). Key differentiator: produces both a long human-readable error with source lines and a short error string. Works with glsl-shader-name for shader naming. Lightweight and focused on WebGL 1.0 error formatting.

npm install gl-format-compiler-error
INSTALL
IMPORT
SIG · GL-FORMAT-COMPILER
G
gl-format-compiler-error
web-frameworkjavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

formatCompilerError
var formatCompilerError = require('gl-format-compiler-error')
import formatCompilerError from 'gl-format-compiler-error'
Package is CJS only; ESM import may fail without bundler or esm shim.

Shows basic usage: compile a shader, capture error, format using the library.

var formatCompilerError = require('gl-format-compiler-error'); var gl = document.createElement('canvas').getContext('webgl'); var shader = gl.createShader(gl.VERTEX_SHADER); gl.shaderSource(shader, 'void main() { gl_Position = vec4(1.0); }'); gl.compileShader(shader); if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { var errLog = gl.getShaderInfoLog(shader); var fmt = formatCompilerError(errLog, shaderSource, gl.VERTEX_SHADER); console.warn(fmt.long); throw new Error(fmt.short); }
Debug
Known issues
gotchaThe 'source' argument must be the exact shader source string passed to gl.shaderSource. Using a different string may produce incorrect line numbers.
fix
Pass the exact source string variable used in gl.shaderSource.
affects: *
gotchaThe 'type' argument expects gl.VERTEX_SHADER or gl.FRAGMENT_SHADER (numeric constants). Passing a different value may produce mislabeled error messages.
fix
Use gl.VERTEX_SHADER or gl.FRAGMENT_SHADER.
affects: *
Errors
Common errors & fixes
TypeError: formatCompilerError is not a function
Using ES import syntax with a CJS-only package.
fix
Use require('gl-format-compiler-error') or configure bundler to handle CJS.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
gl-format-compiler-error — npm install gl-format-compiler-error · libregistry