diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-06-20 18:38:49 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-06-20 18:38:49 -0700 |
commit | b2e7db0e1d8a0cc5317d4ecfe0c359c477fd73df (patch) | |
tree | 56c3b9ef940ff880cc7a9cfca1d04c5f401fec55 | |
parent | 32354b8d83c36054c0038a4eabff7fe40fccc52c (diff) |
prevent shader regex from mixing up lines
-rw-r--r-- | src/webGLWorker.js | 4 | ||||
-rw-r--r-- | tests/sdlglshader2.c | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/webGLWorker.js b/src/webGLWorker.js index 3d521dbe..6dae2b15 100644 --- a/src/webGLWorker.js +++ b/src/webGLWorker.js @@ -577,7 +577,9 @@ function WebGLWorker() { this.linkProgram = function(program) { // parse shader sources function parseElementType(shader, type, obj, vec) { - var newItems = shader.source.match(new RegExp(type + '\\s+\\w+\\s+[\\w,\\s\[\\]]+;', 'g')); + var source = shader.source; + source = source.replace(/\n/g, '|\n'); // barrier between lines, to make regexing easier + var newItems = source.match(new RegExp(type + '\\s+\\w+\\s+[\\w,\\s\[\\]]+;', 'g')); if (!newItems) return; newItems.forEach(function(item) { var m = new RegExp(type + '\\s+\\w+\\s+([\\w,\\s\[\\]]+);').exec(item); diff --git a/tests/sdlglshader2.c b/tests/sdlglshader2.c index 2ec47e87..c75a0f5f 100644 --- a/tests/sdlglshader2.c +++ b/tests/sdlglshader2.c @@ -72,7 +72,8 @@ void setShaders() { GLuint v, f, p; GLint ok; - const char *vv = "uniform vec4 animdata[246];\n" + const char *vv = "#pragma CUBE2_uniform animdata AnimData 0 16\n" + "uniform vec4 animdata[246];\n" "void main() \n" "{ \n" " gl_Position = ftransform() + animdata[0]; \n" |