summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAnsis Brammanis <brammanis@gmail.com>2017-06-16 18:14:12 -0400
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-16 16:10:29 -0700
commit79c986a04c1ef00b3f8eb2bd2251f07b55886702 (patch)
treecd9d09e982bf28f37c178f2f77375046d33d54a9 /scripts
parentafabd2795c95bd11273a370c8045b07296b7a346 (diff)
downloadqtlocation-mapboxgl-79c986a04c1ef00b3f8eb2bd2251f07b55886702.tar.gz
fix shader generation script
the main fix is switching from ifdef -> ifndef The rest of the changes just make a cleaner diff.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate-shaders.js24
1 files changed, 9 insertions, 15 deletions
diff --git a/scripts/generate-shaders.js b/scripts/generate-shaders.js
index 159817f62f..a10e505278 100755
--- a/scripts/generate-shaders.js
+++ b/scripts/generate-shaders.js
@@ -61,7 +61,7 @@ ${fragmentPrelude}
'symbol_icon',
'symbol_sdf'
].forEach(function (shaderName) {
- const re = /#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g;
+ const re = / *#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g;
const fragmentPragmas = new Set();
let fragmentSource = fs.readFileSync(path.join(inputPath, shaderName + '.fragment.glsl'), 'utf8');
@@ -74,47 +74,41 @@ ${fragmentPrelude}
varying ${precision} ${type} ${name};
#else
uniform ${precision} ${type} u_${name};
-#endif
-` : `
+#endif` : `
#ifdef HAS_UNIFORM_u_${name}
${precision} ${type} ${name} = u_${name};
-#endif
-`;
+#endif`;
});
vertexSource = vertexSource.replace(re, (match, operation, precision, type, name) => {
const a_type = type === "float" ? "vec2" : "vec4";
if (fragmentPragmas.has(name)) {
return operation === "define" ? `
-#ifdef HAS_UNIFORM_u_${name}
+#ifndef HAS_UNIFORM_u_${name}
uniform lowp float a_${name}_t;
attribute ${precision} ${a_type} a_${name};
varying ${precision} ${type} ${name};
#else
uniform ${precision} ${type} u_${name};
-#endif
-` : `
+#endif` : `
#ifndef HAS_UNIFORM_u_${name}
${name} = unpack_mix_${a_type}(a_${name}, a_${name}_t);
#else
${precision} ${type} ${name} = u_${name};
-#endif
-`;
+#endif`;
} else {
return operation === "define" ? `
-#ifdef HAS_UNIFORM_u_${name}
+#ifndef HAS_UNIFORM_u_${name}
uniform lowp float a_${name}_t;
attribute ${precision} ${a_type} a_${name};
#else
uniform ${precision} ${type} u_${name};
-#endif
-` : `
+#endif` : `
#ifndef HAS_UNIFORM_u_${name}
${precision} ${type} ${name} = unpack_mix_${a_type}(a_${name}, a_${name}_t);
#else
${precision} ${type} ${name} = u_${name};
-#endif
-`;
+#endif`;
}
});