Add parseUniforms and parseAttributes for WebGL shaders

This commit is contained in:
Christoph Diehl 2018-02-20 03:05:42 +01:00
parent 3ddc37a7e9
commit f0befe57fc
No known key found for this signature in database
GPG key ID: 799CE5B68FEF404A

View file

@ -64,5 +64,23 @@
'ArrayBufferView'
]
return random.item(sources)
},
parseUniforms: (shader) => {
let names = [], result = shader.match(/uniform .* (\w+)(?=;)/gm)
if (result) {
result.forEach(function (v) {
names.push(v.split(" ").pop())
})
}
return names
},
parseAttributes: (shader) => {
let names = [], result = shader.match(/attribute .* (\w+)(?=;)/gm)
if (result) {
result.forEach(function (v) {
names.push(v.split(" ").pop())
})
}
return names
}
}