Skip to content

Experience-Monks/glsl-token-extract-version

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

finds a #version field in a set of GLSL tokens

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published