1.0.1 • Published 9 years ago

glsl-token-extract-version v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

glsl-token-extract-version

stable

Gets the value of a #version statement from a set of GLSL tokens, or returns null if no version is defined.

var tokenize = require('glsl-tokenizer')
var getVersion = require('glsl-token-extract-version')

var source = `
  #version 300 es // WebGL 2
  out vec4 fragColor;

  void main() {
    fragColor = vec4(1.0);
  }
`

var version = getVersion(tokenize(source))
//=> "300 es"

Usage

NPM

version = getVersion(tokens)

For the given list of GLSL tokens, finds a preprocessor statement that matches a #version regex. Normalizes multiple whitespace into a single space, and returns the string value, such as "300 es" or "100".

If no #version statement exists, returns null.

License

MIT, see LICENSE.md for details.