Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gl-format-compiler-error

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gl-format-compiler-error

Formats a webgl glsl compiler error.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25K
increased by16.2%
Maintainers
1
Weekly downloads
 
Created
Source

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"
}

Keywords

FAQs

Package last updated on 05 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc