https://github.com/stackgl/glsl-extract
extract uniforms and attributes from glsl programs
https://github.com/stackgl/glsl-extract
Last synced: about 1 year ago
JSON representation
extract uniforms and attributes from glsl programs
- Host: GitHub
- URL: https://github.com/stackgl/glsl-extract
- Owner: stackgl
- License: mit
- Created: 2013-08-25T09:27:52.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2014-07-05T22:19:15.000Z (almost 12 years ago)
- Last Synced: 2024-04-27T23:20:34.938Z (about 2 years ago)
- Language: JavaScript
- Homepage: http://npm.im/glsl-extract
- Size: 168 KB
- Stars: 19
- Watchers: 9
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.mit
Awesome Lists containing this project
README
# glsl-extract
extract attribute and uniform data from glsl files, no matter how nested.
```javascript
var extract = require('glsl-extract')
extract(fs.createReadStream('test.glsl'))(function(err, info) {
{attributes, uniforms} = info
for(var def of uniforms) {
{name, type} = def // where "name" is the full dotted, array'd
// gl.getUniformLocation lookup path and
// type is the declared type.
}
})
extract("also works with just text")(function(err, info) {
// should execute on same frame.
})
```
# api
### extract(ReadableStream | String | Buffer[, getContextFunction) -> Continuable
Given a readable stream, string, or buffer, return a continuable that will trigger
parsing. The continuable will call its callback with `err` (if any), and `data`,
where `data` is comprised of `{attributes:[GLSLLocation], uniforms:[GLSLLocation]}`.
### GLSLLocation
A GLSLLocation is just a plain object containing `name` (the appropriate name to
pass to `gl.getUniformLocation`) and `type` (one of the primitive GLSL types).
# license
MIT