Skip to content

Commit d1d76f0

Browse files
Olli Etuahophemavax
authored andcommitted
Add ESSL 3.00 support to TDL shader
This is needed to use TDL shaders for multiview rendering. Support is also added for getting the locations of array uniforms.
1 parent 7cf7f6b commit d1d76f0

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tdl/shader.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,24 @@ tdl.shader.Shader = function(gl, vertex, fragment) {
116116
}
117117

118118
// find uniforms and attributes
119-
var re = /(uniform|attribute)\s+\S+\s+(\S+)\s*;/g;
119+
var re = /(uniform|attribute|in)\s+\S+\s+(\w+)\s*(\[\d+\])?\s*;/g;
120120
var match = null;
121-
while ((match = re.exec(vertex + '\n' + fragment)) != null) {
121+
while ((match = re.exec(vertex)) != null) {
122122
var glslName = match[2];
123123
var jsName = tdl.shader.glslNameToJs_(glslName);
124-
var loc = -1;
125124
if (match[1] == "uniform") {
126125
this[jsName + "Loc"] = this.getUniform(glslName);
127-
} else if (match[1] == "attribute") {
126+
} else if (match[1] == "attribute" || match[1] == "in") {
128127
this[jsName + "Loc"] = this.getAttribute(glslName);
129128
}
130-
if (loc >= 0) {
131-
this[jsName + "Loc"] = loc;
129+
}
130+
re = /(uniform)\s+\S+\s+(\w+)\s*(\[\d+\])?\s*;/g;
131+
match = null;
132+
while ((match = re.exec(fragment)) != null) {
133+
var glslName = match[2];
134+
var jsName = tdl.shader.glslNameToJs_(glslName);
135+
if (match[1] == "uniform") {
136+
this[jsName + "Loc"] = this.getUniform(glslName);
132137
}
133138
}
134139
}

0 commit comments

Comments
 (0)