gl-format-compiler-error

WebJar for gl-format-compiler-error

License

License

Categories

Categories

ORM Data
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

gl-format-compiler-error
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

gl-format-compiler-error
WebJar for gl-format-compiler-error
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/wwwtyro/gl-format-compiler-error

Download gl-format-compiler-error

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/gl-format-compiler-error/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>gl-format-compiler-error</artifactId>
    <version>1.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/gl-format-compiler-error/
implementation 'org.webjars.npm:gl-format-compiler-error:1.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/gl-format-compiler-error/
implementation ("org.webjars.npm:gl-format-compiler-error:1.0.3")
'org.webjars.npm:gl-format-compiler-error:jar:1.0.3'
<dependency org="org.webjars.npm" name="gl-format-compiler-error" rev="1.0.3">
  <artifact name="gl-format-compiler-error" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='gl-format-compiler-error', version='1.0.3')
)
libraryDependencies += "org.webjars.npm" % "gl-format-compiler-error" % "1.0.3"
[org.webjars.npm/gl-format-compiler-error "1.0.3"]

Dependencies

compile (4)

Group / Artifact Type Version
org.webjars.npm : add-line-numbers jar [1.0.1,2)
org.webjars.npm : gl-constants jar [1.0.0,2)
org.webjars.npm : glsl-shader-name jar [1.0.0,2)
org.webjars.npm : sprintf-js jar [1.0.3,2)

Project Modules

There are no modules declared in this project.

gl-format-compiler-error

Formats a webgl glsl compiler error. Use in conjunction with glsl-shader-name to include your shader's name in the formatted error string.

Example

    var formatCompilerError = require('gl-format-compiler-error');
    
    ...
    
    var shader = gl.createShader(type)
    gl.shaderSource(shader, src)
    gl.compileShader(shader)
    if(!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
        var errLog = gl.getShaderInfoLog(shader)
        var fmt = formatCompilerError(errLog, src, type);
        console.warn(fmt.long);
        throw new Error(fmt.short);
    }

yields warning:

Error in vertex shader generic:
  13: 
  14: void main() {
  15:     bug;
^^^^: 'bug' : undeclared identifier

  17:     vUV = aUV;
  18:     vPos = vec3(uModel * vec4(aPosition, 1.0))
  19: }
^^^^: '}' : syntax error

and error:

Uncaught Error: Error in vertex shader generic:
ERROR: 0:15: 'bug' : undeclared identifier 
ERROR: 0:19: '}' : syntax error 

Usage

Install

npm install gl-format-compiler-error --save

API

var formatCompilerError = require('gl-format-compiler-error');

fmt = formatCompilerError(errLog, source, type)

Takes errLog result from gl.getShaderInfoLog, the shader source string, and the type of shader, either gl.VERTEX_SHADER or gl.FRAGMENT_SHADER. Returns an object that contains the long and short form of the formatted error:

{
    long: "long form error with code snippets",
    short: "short form error, similar to the original error log"
}

Versions

Version
1.0.3