diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-06-07 14:56:04 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-06-07 15:04:02 +0300 |
commit | 269124ec2624ee9185391e7529ec7eaa4173d8e7 (patch) | |
tree | 74f80d9fed281b3b7a74467378be3ea6264995e2 /scripts | |
parent | 8b28b6ab6b5735a51b15d76baae284658a633c9d (diff) | |
download | qtlocation-mapboxgl-269124ec2624ee9185391e7529ec7eaa4173d8e7.tar.gz |
[core] Include type in #pragmas
Part of https://github.com/mapbox/mapbox-gl-shaders/pull/13.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build-shaders.py | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/scripts/build-shaders.py b/scripts/build-shaders.py index d94a8cdd58..3b02cdc886 100755 --- a/scripts/build-shaders.py +++ b/scripts/build-shaders.py @@ -20,27 +20,21 @@ with open(input_file, "r") as f: # Replace uniform pragmas -pragma_mapbox_regex = re.compile("(\s*)\#pragma \mapbox\: (initialize|define) (.*) (lowp|mediump|highp)") -color_regex = re.compile("(.*)color") +pragma_mapbox_regex = re.compile("(\s*)\#pragma \mapbox\: (define|initialize) (low|medium|high)p (float|vec(2|3|4)) (.*)") def replace_uniform_pragmas(line): - # FIXME We should obtain these from the source code. if pragma_mapbox_regex.match(line): params = line.split() - u_method = params[2] - u_name = params[3] - u_precision = params[4] - u_type = "vec4" if color_regex.match(u_name) else "float" - if u_method == "define": - return """uniform {precision} {type_} u_{name};""".format( - precision = u_precision, - type_ = u_type, - name = u_name) + if params[2] == "define": + return """uniform {u_precision} {u_type} u_{u_name};""".format( + u_precision = params[3], + u_type = params[4], + u_name = params[5]) else: - return """ {precision} {type_} {name} = u_{name};""".format( - precision = u_precision, - type_ = u_type, - name = u_name) + return """ {u_precision} {u_type} {u_name} = u_{u_name};""".format( + u_precision = params[3], + u_type = params[4], + u_name = params[5]) else: return line |