diff --git a/.gitignore b/.gitignore index b8cbcf58e..a85ec0014 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ /include/llmr/shader/shaders.hpp /include/llmr/style/resources.hpp /src/style/resources.cpp +/src/shader/shaders_gl.cpp +/src/shader/shaders_gles2.cpp \ No newline at end of file diff --git a/bin/build-shaders.js b/bin/build-shaders.js index 445006633..b5072c370 100755 --- a/bin/build-shaders.js +++ b/bin/build-shaders.js @@ -3,7 +3,7 @@ var fs = require('fs'); var path = require('path'); -var lazy_update = require('./lazy-update'); +var mkdirp = require('./mkdirp'); try { var glsl = require('glsl-optimizer'); } catch(err) {} @@ -117,9 +117,13 @@ module.exports = function(shader_type, prefix, suffix) { code += '\n};\n'; code += suffix + '\n'; + var file_path = path.join(process.argv[2], 'include/llmr/shader/shaders.hpp'); + mkdirp.sync(path.dirname(file_path)); + fs.writeFileSync(file_path, header); + var header_path = path.join(process.argv[2], 'src/shader/shaders_' + shader_type + '.cpp'); + mkdirp.sync(path.dirname(header_path)); + fs.writeFileSync(header_path, code); - lazy_update('include/llmr/shader/shaders.hpp', header); - lazy_update('src/shader/shaders_' + shader_type + '.cpp', code); }; module.exports('gl', '#ifndef GL_ES_VERSION_2_0', '#endif'); diff --git a/bin/build-style.js b/bin/build-style.js index bd86d5bda..932287b89 100755 --- a/bin/build-style.js +++ b/bin/build-style.js @@ -2,9 +2,8 @@ 'use strict'; var path = require('path'); - -var lazy_update = require('./lazy-update'); - +var fs = require('fs'); +var mkdirp = require('./mkdirp'); var name = 'style'; var data = JSON.stringify(require(path.join(process.cwd(), process.argv[2]))); @@ -26,7 +25,9 @@ header += '}\n'; header += '\n'; header += '#endif\n'; -lazy_update('include/llmr/style/resources.hpp', header); +var header_path = path.join(process.argv[3], 'include/llmr/style/resources.hpp'); +mkdirp.sync(path.dirname(header_path)); +fs.writeFileSync(header_path, header); var code = '// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.\n'; code += '#include \n'; @@ -36,5 +37,6 @@ code += '\n'; code += 'const unsigned char resources::' + name + '[] = R"JSON(' + data + ')JSON";\n'; code += 'const unsigned long resources::' + name + '_size = sizeof(resources::' + name + ');\n'; -lazy_update('src/style/resources.cpp', code); - +var file_path = path.join(process.argv[3], 'src/style/resources.cpp'); +mkdirp.sync(path.dirname(file_path)); +fs.writeFileSync(file_path, code); diff --git a/bin/mkdirp.js b/bin/mkdirp.js new file mode 100644 index 000000000..a1742b206 --- /dev/null +++ b/bin/mkdirp.js @@ -0,0 +1,97 @@ +var path = require('path'); +var fs = require('fs'); + +module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP; + +function mkdirP (p, opts, f, made) { + if (typeof opts === 'function') { + f = opts; + opts = {}; + } + else if (!opts || typeof opts !== 'object') { + opts = { mode: opts }; + } + + var mode = opts.mode; + var xfs = opts.fs || fs; + + if (mode === undefined) { + mode = 0777 & (~process.umask()); + } + if (!made) made = null; + + var cb = f || function () {}; + p = path.resolve(p); + + xfs.mkdir(p, mode, function (er) { + if (!er) { + made = made || p; + return cb(null, made); + } + switch (er.code) { + case 'ENOENT': + mkdirP(path.dirname(p), opts, function (er, made) { + if (er) cb(er, made); + else mkdirP(p, opts, cb, made); + }); + break; + + // In the case of any other error, just see if there's a dir + // there already. If so, then hooray! If not, then something + // is borked. + default: + xfs.stat(p, function (er2, stat) { + // if the stat fails, then that's super weird. + // let the original error be the failure reason. + if (er2 || !stat.isDirectory()) cb(er, made) + else cb(null, made); + }); + break; + } + }); +} + +mkdirP.sync = function sync (p, opts, made) { + if (!opts || typeof opts !== 'object') { + opts = { mode: opts }; + } + + var mode = opts.mode; + var xfs = opts.fs || fs; + + if (mode === undefined) { + mode = 0777 & (~process.umask()); + } + if (!made) made = null; + + p = path.resolve(p); + + try { + xfs.mkdirSync(p, mode); + made = made || p; + } + catch (err0) { + switch (err0.code) { + case 'ENOENT' : + made = sync(path.dirname(p), opts, made); + sync(p, opts, made); + break; + + // In the case of any other error, just see if there's a dir + // there already. If so, then hooray! If not, then something + // is borked. + default: + var stat; + try { + stat = xfs.statSync(p); + } + catch (err1) { + throw err0; + } + if (!stat.isDirectory()) throw err0; + break; + } + } + + return made; +}; diff --git a/bin/style.js b/bin/style.js index 5c8ada38c..6be96c965 100644 --- a/bin/style.js +++ b/bin/style.js @@ -1376,10 +1376,11 @@ module.exports = { "admin_night": "#ffb680", "text_night": "#fff", "text_stroke_night": "#103", + "text2_stroke_night": "rgba(1,69,89,0.8)", "case_night": "#015e7a", "street_case_night": "#015b76", - "motorway_night": "#eee", + "motorway_night": "#bbdde7", "main_night": "#64b2c9", "street_night": "#0186ac", "contour_night": "#ffff80", @@ -2260,8 +2261,11 @@ module.exports = { "stroke": "text_stroke" }, "poi": { - "color": "rgba(50,50,50,0.9)", + //"color": "rgba(50,50,50,0.9)", "antialias": false + //"stroke": #000, + //"strokeWidth": 0.4, + //"strokeBlur": 2 }, "poi_label": { "color": "#444", @@ -2949,7 +2953,7 @@ module.exports = { }, "road_label": { "color": "text_night", - "stroke": "text_stroke_night", + "stroke": "text2_stroke_night", "strokeWidth": 0.5, "strokeBlur": 3, "size": "road_label_size" @@ -2970,9 +2974,9 @@ module.exports = { "poi_label": { "color": "#fff", "size": 10, - "stroke": "land_night", - "strokeWidth": 0.4, - "strokeBlur": 0.2, + "stroke": "text2_stroke_night", + "strokeWidth": 0.3, + "strokeBlur": 2, "translate": [0, 14] }, "poi_aerodrome": { diff --git a/common.gypi b/common.gypi index b81a361f5..b1ad46015 100644 --- a/common.gypi +++ b/common.gypi @@ -12,14 +12,20 @@ 'cflags': [ '-g', '-O0' ], 'defines': [ 'DEBUG' ], 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS': [ '-Wall', '-Wextra', '-pedantic', '-g', '-O0' ] + 'GCC_OPTIMIZATION_LEVEL': '0', + 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES', + 'OTHER_CPLUSPLUSFLAGS': [ '-Wall', '-Wextra', '-pedantic' ] } }, 'Release': { 'cflags': [ '-O3' ], 'defines': [ 'NDEBUG' ], 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS': [ '-Wall', '-Wextra', '-pedantic', '-O3' ] + 'GCC_OPTIMIZATION_LEVEL': '3', + 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO', + 'DEAD_CODE_STRIPPING': 'YES', + 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES', + 'OTHER_CPLUSPLUSFLAGS': [ '-Wall', '-Wextra', '-pedantic' ] } } } diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp index 9590cc5e7..3cc50b591 100644 --- a/common/glfw_view.cpp +++ b/common/glfw_view.cpp @@ -273,5 +273,9 @@ void show_color_debug_image(std::string name, const char *data, size_t logical_w glfwMakeContextCurrent(current_window); } +void notify_map_change() { + // no-op +} + } } diff --git a/include/llmr/map/map.hpp b/include/llmr/map/map.hpp index 918d20335..ab1738f96 100644 --- a/include/llmr/map/map.hpp +++ b/include/llmr/map/map.hpp @@ -5,8 +5,6 @@ #include #include -// #include -// #include #include #include #include @@ -75,6 +73,8 @@ public: void resetZoom(); void startScaling(); void stopScaling(); + double getMinZoom(); + double getMaxZoom(); // Rotation void rotateBy(double sx, double sy, double ex, double ey, double duration = 0); @@ -84,6 +84,7 @@ public: void resetNorth(); void startRotating(); void stopRotating(); + bool canRotate(); // Debug void setDebug(bool value); diff --git a/include/llmr/map/transform.hpp b/include/llmr/map/transform.hpp index 4226ec7e4..6ab3d4b84 100644 --- a/include/llmr/map/transform.hpp +++ b/include/llmr/map/transform.hpp @@ -37,16 +37,19 @@ public: void setZoom(double zoom, time duration = 0); double getZoom() const; double getScale() const; - void startRotating(); - void stopRotating(); + void startScaling(); + void stopScaling(); + double getMinZoom(); + double getMaxZoom(); // Angle void rotateBy(double sx, double sy, double ex, double ey, time duration = 0); void setAngle(double angle, time duration = 0); void setAngle(double angle, double cx, double cy); double getAngle() const; - void startScaling(); - void stopScaling(); + void startRotating(); + void stopRotating(); + bool canRotate(); // Transitions bool needsTransition() const; @@ -63,7 +66,7 @@ private: void _moveBy(double dx, double dy, time duration = 0); void _setScale(double scale, double cx, double cy, time duration = 0); void _setScaleXY(double new_scale, double xn, double yn, time duration = 0); - void _setAngle(double angle, time duration = 0); + void _setAngle(double angle, time duration = 0, bool disable_interaction = false); void _clearPanning(); void _clearRotating(); void _clearScaling(); @@ -93,6 +96,7 @@ private: std::shared_ptr scale_timeout; std::shared_ptr rotate_timeout; std::shared_ptr pan_timeout; + std::shared_ptr interaction_timeout; }; } diff --git a/include/llmr/map/transform_state.hpp b/include/llmr/map/transform_state.hpp index 29d0f59c4..b3794e909 100644 --- a/include/llmr/map/transform_state.hpp +++ b/include/llmr/map/transform_state.hpp @@ -39,6 +39,9 @@ public: // Changing bool isChanging() const; + // Interactive + bool isInteractive() const; + private: double pixel_x() const; double pixel_y() const; @@ -57,6 +60,7 @@ private: bool rotating = false; bool scaling = false; bool panning = false; + bool interactive = true; // map position double x = 0, y = 0; diff --git a/include/llmr/platform/platform.hpp b/include/llmr/platform/platform.hpp index 62fa1badc..972e7db6b 100644 --- a/include/llmr/platform/platform.hpp +++ b/include/llmr/platform/platform.hpp @@ -32,6 +32,9 @@ std::shared_ptr request_http(const std::string &url, // Cancels an HTTP request. void cancel_request_http(const std::shared_ptr &req); +// Notifies a watcher of map x/y/scale/rotation changes. +void notify_map_change(); + // Shows an alpha image with the specified dimensions in a named window. void show_debug_image(std::string name, const char *data, size_t width, size_t height); diff --git a/llmr.gyp b/llmr.gyp index 4c2086242..a32a598f5 100644 --- a/llmr.gyp +++ b/llmr.gyp @@ -19,9 +19,19 @@ 'src/shader/shaders_gl.cpp', 'src/shader/shaders_gles2.cpp', ], - 'action': ['<@(node)', 'bin/build-shaders.js'], + 'action': ['<@(node)', 'bin/build-shaders.js', '<(SHARED_INTERMEDIATE_DIR)'], } - ] + ], + 'direct_dependent_settings': { + 'sources': [ + '<(SHARED_INTERMEDIATE_DIR)/include/llmr/shader/shaders.hpp', + '<(SHARED_INTERMEDIATE_DIR)/src/shader/shaders_gl.cpp', + '<(SHARED_INTERMEDIATE_DIR)/src/shader/shaders_gles2.cpp' + ], + 'include_dirs':[ + '<(SHARED_INTERMEDIATE_DIR)/include/', + ] + } }, { 'target_name': 'build_stylesheet', @@ -34,15 +44,19 @@ 'bin/style.js', ], 'outputs': [ - 'include/llmr/style/resources.hpp', - 'src/style/resources.cpp' + '<(SHARED_INTERMEDIATE_DIR)/include/llmr/style/resources.hpp', + '<(SHARED_INTERMEDIATE_DIR)/src/style/resources.cpp' ], - 'action': ['<@(node)', 'bin/build-style.js', '<@(_inputs)'] + 'action': ['<@(node)', 'bin/build-style.js', '<@(_inputs)', '<(SHARED_INTERMEDIATE_DIR)'] } ], 'direct_dependent_settings': { 'sources': [ - 'src/style/resources.cpp' + '<(SHARED_INTERMEDIATE_DIR)/include/llmr/style/resources.hpp', + '<(SHARED_INTERMEDIATE_DIR)/src/style/resources.cpp' + ], + 'include_dirs':[ + '<(SHARED_INTERMEDIATE_DIR)/include/', ] } }, @@ -121,7 +135,7 @@ 'shaders', ], 'sources': [ - '>(current.y, final.y, current.y, start, duration)); } + + platform::notify_map_change(); } void Transform::setLonLat(const double lon, const double lat, const time duration) { @@ -197,6 +206,18 @@ void Transform::stopScaling() { _clearScaling(); } +double Transform::getMinZoom() { + double test_scale = current.scale; + double test_y = current.y; + constrain(test_scale, test_y); + + return std::log2(std::fmin(min_scale, test_scale)); +} + +double Transform::getMaxZoom() { + return std::log2(max_scale); +} + void Transform::_clearScaling() { // This is only called internally, so we don't need a lock here. @@ -251,7 +272,7 @@ void Transform::_setScaleXY(const double new_scale, const double xn, const doubl constrain(final.scale, final.y); // Undo rotation at low zooms. - if (final.scale < MIN_ROTATE_SCALE && current.angle) _setAngle(0, 500_milliseconds); + if (!canRotate() && current.angle) _setAngle(0, 500_milliseconds, true); if (duration == 0) { current.scale = final.scale; @@ -272,6 +293,8 @@ void Transform::_setScaleXY(const double new_scale, const double xn, const doubl zc = s / 2; Bc = s / 360; Cc = s / (2 * M_PI); + + platform::notify_map_change(); } #pragma mark - Constraints @@ -344,7 +367,7 @@ void Transform::setAngle(const double new_angle, const double cx, const double c } } -void Transform::_setAngle(double new_angle, const time duration) { +void Transform::_setAngle(double new_angle, const time duration, bool disable_interaction) { // This is only called internally, so we don't need a lock here. while (new_angle > M_PI) @@ -355,15 +378,25 @@ void Transform::_setAngle(double new_angle, const time duration) { final.angle = new_angle; // Prevent rotation at low zooms. - if (final.scale < MIN_ROTATE_SCALE) final.angle = 0; + if (!canRotate()) final.angle = 0; if (duration == 0) { current.angle = final.angle; + transitions.remove(interaction_timeout); + current.interactive = true; } else { time start = util::now(); transitions.emplace_front(std::make_shared>( current.angle, final.angle, current.angle, start, duration)); + if (disable_interaction) { + transitions.remove(interaction_timeout); + current.interactive = false; + interaction_timeout = std::make_shared>(true, current.interactive, start, duration); + transitions.emplace_front(interaction_timeout); + } } + + platform::notify_map_change(); } double Transform::getAngle() const { @@ -400,6 +433,10 @@ void Transform::_clearRotating() { } } +bool Transform::canRotate() { + return (current.scale >= MIN_ROTATE_SCALE); +} + #pragma mark - Transition bool Transform::needsTransition() const { diff --git a/src/map/transform_state.cpp b/src/map/transform_state.cpp index c22678a4e..0d495fc6d 100644 --- a/src/map/transform_state.cpp +++ b/src/map/transform_state.cpp @@ -115,13 +115,20 @@ float TransformState::getAngle() const { } -#pragma mark - Rotation +#pragma mark - Changing bool TransformState::isChanging() const { return rotating || scaling || panning; } +#pragma mark - Interactive + +bool TransformState::isInteractive() const { + return interactive; +} + + #pragma mark - (private helper functions) diff --git a/src/shader/shaders_gl.cpp b/src/shader/shaders_gl.cpp deleted file mode 100644 index fab63485f..000000000 --- a/src/shader/shaders_gl.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -#include -#ifndef GL_ES_VERSION_2_0 -#include - -using namespace llmr; - -const shader_source llmr::shaders[SHADER_COUNT] = { - { - "#version 120\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nvarying vec2 v_pos;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n vec4 tmpvar_2;\n tmpvar_2 = (u_matrix * tmpvar_1);\n gl_Position = tmpvar_2;\n v_pos = ((tmpvar_2.xy + 1.0) / 2.0);\n}\n\n", - "#version 120\nuniform sampler2D u_image;\nuniform float u_opacity;\nvarying vec2 v_pos;\nvoid main ()\n{\n gl_FragColor = (texture2D (u_image, v_pos) * u_opacity);\n}\n\n", - }, - { - "#version 120\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform float u_size;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n gl_PointSize = u_size;\n}\n\n", - "#version 120\nuniform vec4 u_color;\nuniform float u_blur;\nvoid main ()\n{\n vec2 x_1;\n x_1 = (gl_PointCoord - 0.5);\n float tmpvar_2;\n tmpvar_2 = clamp (((\n sqrt(dot (x_1, x_1))\n - 0.5) / (\n (0.5 - u_blur)\n - 0.5)), 0.0, 1.0);\n gl_FragColor = (u_color * (tmpvar_2 * (tmpvar_2 * \n (3.0 - (2.0 * tmpvar_2))\n )));\n}\n\n", - }, - { - "#version 120\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform vec2 u_offset;\nvarying vec2 v_coords[3];\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n vec4 tmpvar_2;\n tmpvar_2 = (u_matrix * tmpvar_1);\n gl_Position = tmpvar_2;\n vec2 tmpvar_3;\n tmpvar_3 = ((tmpvar_2.xy + 1.0) / 2.0);\n v_coords[0] = tmpvar_3;\n vec2 cse_4;\n cse_4 = (u_offset * 1.18243);\n v_coords[1] = (tmpvar_3 + cse_4);\n v_coords[2] = (tmpvar_3 - cse_4);\n}\n\n", - "#version 120\nuniform sampler2D u_image;\nvarying vec2 v_coords[3];\nvoid main ()\n{\n gl_FragColor = (((texture2D (u_image, v_coords[0]) * 0.40262) + (texture2D (u_image, v_coords[1]) * 0.29869)) + (texture2D (u_image, v_coords[2]) * 0.29869));\n}\n\n", - }, - { - "#version 120\nattribute vec2 a_pos;\nattribute vec2 a_tex;\nuniform mat4 u_matrix;\nuniform float u_size;\nuniform float u_ratio;\nvarying vec2 v_tex;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n gl_PointSize = u_size;\n v_tex = (a_tex * u_ratio);\n}\n\n", - "#version 120\nuniform sampler2D u_image;\nuniform vec2 u_dimension;\nuniform vec4 u_color;\nuniform float u_size;\nvarying vec2 v_tex;\nvoid main ()\n{\n gl_FragColor = (u_color * texture2D (u_image, ((v_tex + \n ((gl_PointCoord - 0.5) * u_size)\n ) / u_dimension)));\n}\n\n", - }, - { - "#version 120\nattribute vec2 a_pos;\nattribute vec2 a_extrude;\nattribute float a_linesofar;\nuniform mat4 u_matrix;\nuniform mat4 u_exmatrix;\nuniform float u_ratio;\nuniform vec2 u_linewidth;\nvarying vec2 v_normal;\nvarying float v_linesofar;\nvoid main ()\n{\n vec2 normal_1;\n vec2 tmpvar_2;\n tmpvar_2 = (vec2(mod (a_pos, 2.0)));\n normal_1.x = tmpvar_2.x;\n normal_1.y = sign((tmpvar_2.y - 0.5));\n v_normal = normal_1;\n vec4 tmpvar_3;\n tmpvar_3.zw = vec2(0.0, 0.0);\n tmpvar_3.xy = ((u_linewidth.x * a_extrude) * 0.015873);\n vec4 tmpvar_4;\n tmpvar_4.zw = vec2(0.0, 1.0);\n tmpvar_4.xy = floor((a_pos * 0.5));\n gl_Position = ((u_matrix * tmpvar_4) + (u_exmatrix * tmpvar_3));\n v_linesofar = (a_linesofar * u_ratio);\n}\n\n", - "#version 120\nuniform vec2 u_linewidth;\nuniform vec4 u_color;\nuniform vec2 u_dasharray;\nvarying vec2 v_normal;\nvarying float v_linesofar;\nvoid main ()\n{\n float tmpvar_1;\n tmpvar_1 = (sqrt(dot (v_normal, v_normal)) * u_linewidth.x);\n float tmpvar_2;\n tmpvar_2 = (float(mod (v_linesofar, (u_dasharray.x + u_dasharray.y))));\n gl_FragColor = (u_color * (clamp (\n min ((tmpvar_1 - (u_linewidth.y - 1.0)), (u_linewidth.x - tmpvar_1))\n , 0.0, 1.0) * max (\n float((-(u_dasharray.y) >= 0.0))\n , \n clamp (min (tmpvar_2, (u_dasharray.x - tmpvar_2)), 0.0, 1.0)\n )));\n}\n\n", - }, - { - "#version 120\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform vec2 u_world;\nuniform float u_size;\nvarying vec2 v_pos;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = floor((a_pos / 2.0));\n vec4 tmpvar_2;\n tmpvar_2 = (u_matrix * tmpvar_1);\n gl_Position = tmpvar_2;\n v_pos = ((tmpvar_2.xy + 1.0) * u_world);\n gl_PointSize = u_size;\n}\n\n", - "#version 120\nuniform vec4 u_color;\nuniform vec2 u_linewidth;\nvarying vec2 v_pos;\nvoid main ()\n{\n float tmpvar_1;\n vec2 x_2;\n x_2 = (v_pos - gl_FragCoord.xy);\n tmpvar_1 = sqrt(dot (x_2, x_2));\n gl_FragColor = (u_color * clamp (min (\n (tmpvar_1 - (u_linewidth.y - 1.0))\n , \n (u_linewidth.x - tmpvar_1)\n ), 0.0, 1.0));\n}\n\n", - }, - { - "#version 120\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform vec2 u_world;\nvarying vec2 v_pos;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n vec4 tmpvar_2;\n tmpvar_2 = (u_matrix * tmpvar_1);\n gl_Position = tmpvar_2;\n v_pos = (((tmpvar_2.xy + 1.0) / 2.0) * u_world);\n}\n\n", - "#version 120\nuniform vec4 u_color;\nvarying vec2 v_pos;\nvoid main ()\n{\n vec2 x_1;\n x_1 = (v_pos - gl_FragCoord.xy);\n float tmpvar_2;\n tmpvar_2 = clamp (((\n sqrt(dot (x_1, x_1))\n - 1.0) / -1.0), 0.0, 1.0);\n gl_FragColor = (u_color * (tmpvar_2 * (tmpvar_2 * \n (3.0 - (2.0 * tmpvar_2))\n )));\n}\n\n", - }, - { - "#version 120\nuniform mat4 u_matrix;\nattribute vec2 a_pos;\nvarying vec2 v_pos;\nvoid main ()\n{\n v_pos = a_pos;\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n}\n\n", - "#version 120\nuniform vec4 u_color;\nuniform vec2 u_offset;\nuniform vec2 u_pattern_size;\nuniform vec2 u_pattern_tl;\nuniform vec2 u_pattern_br;\nuniform float u_mix;\nuniform sampler2D u_image;\nvarying vec2 v_pos;\nvoid main ()\n{\n vec2 tmpvar_1;\n tmpvar_1 = (vec2(mod (((v_pos + u_offset) / u_pattern_size), 1.0)));\n vec4 tmpvar_2;\n tmpvar_2 = mix (texture2D (u_image, mix (u_pattern_tl, u_pattern_br, tmpvar_1)), texture2D (u_image, mix (u_pattern_tl, u_pattern_br, (vec2(mod (\n (tmpvar_1 * 2.0)\n , 1.0))))), u_mix);\n gl_FragColor = (tmpvar_2 + (u_color * (1.0 - tmpvar_2.w)));\n}\n\n", - }, - { - "#version 120\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n}\n\n", - "#version 120\nuniform vec4 u_color;\nvoid main ()\n{\n gl_FragColor = u_color;\n}\n\n", - }, - { - "#version 120\nuniform mat4 u_matrix;\nuniform float u_buffer;\nattribute vec2 a_pos;\nvarying vec2 v_pos;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n float tmpvar_2;\n tmpvar_2 = (4096.0 + (2.0 * u_buffer));\n v_pos = ((a_pos / tmpvar_2) + (u_buffer / tmpvar_2));\n}\n\n", - "#version 120\nuniform sampler2D u_image;\nuniform float u_opacity;\nvarying vec2 v_pos;\nvoid main ()\n{\n gl_FragColor = (texture2D (u_image, v_pos, 2.0) * u_opacity);\n}\n\n", - }, - { - "#version 120\nattribute vec2 a_pos;\nattribute vec2 a_offset;\nattribute vec4 a_data1;\nattribute vec4 a_data2;\nuniform mat4 u_matrix;\nuniform mat4 u_exmatrix;\nuniform float u_angle;\nuniform float u_zoom;\nuniform float u_flip;\nuniform float u_fadedist;\nuniform float u_minfadezoom;\nuniform float u_maxfadezoom;\nuniform float u_fadezoom;\nuniform vec2 u_texsize;\nvarying vec2 v_tex;\nvarying float v_alpha;\nvoid main ()\n{\n float rev_1;\n rev_1 = 0.0;\n float tmpvar_2;\n tmpvar_2 = (float(mod ((a_data1.w + u_angle), 256.0)));\n if ((((u_flip > 0.0) && (tmpvar_2 >= 64.0)) && (tmpvar_2 < 192.0))) {\n rev_1 = 1.0;\n };\n float tmpvar_3;\n tmpvar_3 = (((2.0 - \n float((u_zoom >= a_data2.x))\n ) - (1.0 - \n float((u_zoom >= a_data2.y))\n )) + rev_1);\n float tmpvar_4;\n tmpvar_4 = clamp (((u_fadezoom - a_data1.z) / u_fadedist), 0.0, 1.0);\n if ((u_fadedist >= 0.0)) {\n v_alpha = tmpvar_4;\n } else {\n v_alpha = (1.0 - tmpvar_4);\n };\n if ((u_maxfadezoom < a_data1.z)) {\n v_alpha = 0.0;\n };\n if ((u_minfadezoom >= a_data1.z)) {\n v_alpha = 1.0;\n };\n vec4 tmpvar_5;\n tmpvar_5.zw = vec2(0.0, 1.0);\n tmpvar_5.xy = a_pos;\n vec4 tmpvar_6;\n tmpvar_6.w = 0.0;\n tmpvar_6.xy = (a_offset / 64.0);\n tmpvar_6.z = ((tmpvar_3 + float(\n (0.0 >= v_alpha)\n )) + (float(\n (u_angle >= a_data2.z)\n ) * (1.0 - \n float((u_angle >= a_data2.w))\n )));\n gl_Position = ((u_matrix * tmpvar_5) + (u_exmatrix * tmpvar_6));\n v_tex = ((a_data1.xy * 4.0) / u_texsize);\n}\n\n", - "#version 120\nuniform sampler2D u_texture;\nuniform vec4 u_color;\nuniform float u_buffer;\nuniform float u_gamma;\nvarying vec2 v_tex;\nvarying float v_alpha;\nvoid main ()\n{\n float edge0_1;\n edge0_1 = (u_buffer - u_gamma);\n float tmpvar_2;\n tmpvar_2 = clamp (((texture2D (u_texture, v_tex).w - edge0_1) / (\n (u_buffer + u_gamma)\n - edge0_1)), 0.0, 1.0);\n gl_FragColor = (u_color * ((tmpvar_2 * \n (tmpvar_2 * (3.0 - (2.0 * tmpvar_2)))\n ) * v_alpha));\n}\n\n", - } -}; -#endif diff --git a/src/shader/shaders_gles2.cpp b/src/shader/shaders_gles2.cpp deleted file mode 100644 index ce17d1bbc..000000000 --- a/src/shader/shaders_gles2.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -#include -#ifdef GL_ES_VERSION_2_0 -#include - -using namespace llmr; - -const shader_source llmr::shaders[SHADER_COUNT] = { - { - "precision highp float;\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nvarying highp vec2 v_pos;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n vec4 tmpvar_2;\n tmpvar_2 = (u_matrix * tmpvar_1);\n gl_Position = tmpvar_2;\n v_pos = ((tmpvar_2.xy + 1.0) / 2.0);\n}\n\n", - "precision highp float;\nuniform sampler2D u_image;\nuniform float u_opacity;\nvarying vec2 v_pos;\nvoid main ()\n{\n lowp vec4 tmpvar_1;\n tmpvar_1 = (texture2D (u_image, v_pos) * u_opacity);\n gl_FragColor = tmpvar_1;\n}\n\n", - }, - { - "precision highp float;\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform float u_size;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n gl_PointSize = u_size;\n}\n\n", - "precision highp float;\nuniform vec4 u_color;\nuniform float u_blur;\nvoid main ()\n{\n mediump vec2 x_1;\n x_1 = (gl_PointCoord - 0.5);\n mediump float tmpvar_2;\n tmpvar_2 = clamp (((\n sqrt(dot (x_1, x_1))\n - 0.5) / (\n (0.5 - u_blur)\n - 0.5)), 0.0, 1.0);\n gl_FragColor = (u_color * (tmpvar_2 * (tmpvar_2 * \n (3.0 - (2.0 * tmpvar_2))\n )));\n}\n\n", - }, - { - "precision highp float;\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform vec2 u_offset;\nvarying highp vec2 v_coords[3];\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n vec4 tmpvar_2;\n tmpvar_2 = (u_matrix * tmpvar_1);\n gl_Position = tmpvar_2;\n highp vec2 tmpvar_3;\n tmpvar_3 = ((tmpvar_2.xy + 1.0) / 2.0);\n v_coords[0] = tmpvar_3;\n vec2 cse_4;\n cse_4 = (u_offset * 1.18243);\n v_coords[1] = (tmpvar_3 + cse_4);\n v_coords[2] = (tmpvar_3 - cse_4);\n}\n\n", - "precision highp float;\nuniform sampler2D u_image;\nvarying vec2 v_coords[3];\nvoid main ()\n{\n lowp vec4 tmpvar_1;\n tmpvar_1 = (((texture2D (u_image, v_coords[0]) * 0.40262) + (texture2D (u_image, v_coords[1]) * 0.29869)) + (texture2D (u_image, v_coords[2]) * 0.29869));\n gl_FragColor = tmpvar_1;\n}\n\n", - }, - { - "precision highp float;\nattribute vec2 a_pos;\nattribute vec2 a_tex;\nuniform mat4 u_matrix;\nuniform float u_size;\nuniform float u_ratio;\nvarying vec2 v_tex;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n gl_PointSize = u_size;\n v_tex = (a_tex * u_ratio);\n}\n\n", - "precision highp float;\nuniform sampler2D u_image;\nuniform vec2 u_dimension;\nuniform vec4 u_color;\nuniform float u_size;\nvarying vec2 v_tex;\nvoid main ()\n{\n mediump vec2 tmpvar_1;\n tmpvar_1 = ((v_tex + (\n (gl_PointCoord - 0.5)\n * u_size)) / u_dimension);\n lowp vec4 tmpvar_2;\n tmpvar_2 = (u_color * texture2D (u_image, tmpvar_1));\n gl_FragColor = tmpvar_2;\n}\n\n", - }, - { - "precision highp float;\nattribute vec2 a_pos;\nattribute vec2 a_extrude;\nattribute float a_linesofar;\nuniform mat4 u_matrix;\nuniform mat4 u_exmatrix;\nuniform float u_ratio;\nuniform vec2 u_linewidth;\nvarying vec2 v_normal;\nvarying float v_linesofar;\nvoid main ()\n{\n vec2 normal_1;\n vec2 tmpvar_2;\n tmpvar_2 = (vec2(mod (a_pos, 2.0)));\n normal_1.x = tmpvar_2.x;\n normal_1.y = sign((tmpvar_2.y - 0.5));\n v_normal = normal_1;\n vec4 tmpvar_3;\n tmpvar_3.zw = vec2(0.0, 0.0);\n tmpvar_3.xy = ((u_linewidth.x * a_extrude) * 0.015873);\n vec4 tmpvar_4;\n tmpvar_4.zw = vec2(0.0, 1.0);\n tmpvar_4.xy = floor((a_pos * 0.5));\n gl_Position = ((u_matrix * tmpvar_4) + (u_exmatrix * tmpvar_3));\n v_linesofar = (a_linesofar * u_ratio);\n}\n\n", - "precision highp float;\nuniform vec2 u_linewidth;\nuniform vec4 u_color;\nuniform vec2 u_dasharray;\nvarying vec2 v_normal;\nvarying float v_linesofar;\nvoid main ()\n{\n float tmpvar_1;\n tmpvar_1 = (sqrt(dot (v_normal, v_normal)) * u_linewidth.x);\n float tmpvar_2;\n tmpvar_2 = (float(mod (v_linesofar, (u_dasharray.x + u_dasharray.y))));\n gl_FragColor = (u_color * (clamp (\n min ((tmpvar_1 - (u_linewidth.y - 1.0)), (u_linewidth.x - tmpvar_1))\n , 0.0, 1.0) * max (\n float((-(u_dasharray.y) >= 0.0))\n , \n clamp (min (tmpvar_2, (u_dasharray.x - tmpvar_2)), 0.0, 1.0)\n )));\n}\n\n", - }, - { - "precision highp float;\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform vec2 u_world;\nuniform float u_size;\nvarying highp vec2 v_pos;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = floor((a_pos / 2.0));\n vec4 tmpvar_2;\n tmpvar_2 = (u_matrix * tmpvar_1);\n gl_Position = tmpvar_2;\n v_pos = ((tmpvar_2.xy + 1.0) * u_world);\n gl_PointSize = u_size;\n}\n\n", - "precision highp float;\nuniform vec4 u_color;\nuniform vec2 u_linewidth;\nvarying vec2 v_pos;\nvoid main ()\n{\n highp float tmpvar_1;\n highp vec2 x_2;\n x_2 = (v_pos - gl_FragCoord.xy);\n tmpvar_1 = sqrt(dot (x_2, x_2));\n highp vec4 tmpvar_3;\n tmpvar_3 = (u_color * clamp (min (\n (tmpvar_1 - (u_linewidth.y - 1.0))\n , \n (u_linewidth.x - tmpvar_1)\n ), 0.0, 1.0));\n gl_FragColor = tmpvar_3;\n}\n\n", - }, - { - "precision highp float;\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nuniform vec2 u_world;\nvarying highp vec2 v_pos;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n vec4 tmpvar_2;\n tmpvar_2 = (u_matrix * tmpvar_1);\n gl_Position = tmpvar_2;\n v_pos = (((tmpvar_2.xy + 1.0) / 2.0) * u_world);\n}\n\n", - "precision highp float;\nuniform vec4 u_color;\nvarying vec2 v_pos;\nvoid main ()\n{\n highp vec2 x_1;\n x_1 = (v_pos - gl_FragCoord.xy);\n highp float tmpvar_2;\n tmpvar_2 = clamp (((\n sqrt(dot (x_1, x_1))\n - 1.0) / -1.0), 0.0, 1.0);\n highp vec4 tmpvar_3;\n tmpvar_3 = (u_color * (tmpvar_2 * (tmpvar_2 * \n (3.0 - (2.0 * tmpvar_2))\n )));\n gl_FragColor = tmpvar_3;\n}\n\n", - }, - { - "precision highp float;\nuniform mat4 u_matrix;\nattribute vec2 a_pos;\nvarying vec2 v_pos;\nvoid main ()\n{\n v_pos = a_pos;\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n}\n\n", - "precision highp float;\nuniform vec4 u_color;\nuniform vec2 u_offset;\nuniform vec2 u_pattern_size;\nuniform vec2 u_pattern_tl;\nuniform vec2 u_pattern_br;\nuniform float u_mix;\nuniform sampler2D u_image;\nvarying vec2 v_pos;\nvoid main ()\n{\n vec2 tmpvar_1;\n tmpvar_1 = (vec2(mod (((v_pos + u_offset) / u_pattern_size), 1.0)));\n lowp vec4 tmpvar_2;\n tmpvar_2 = mix (texture2D (u_image, mix (u_pattern_tl, u_pattern_br, tmpvar_1)), texture2D (u_image, mix (u_pattern_tl, u_pattern_br, (vec2(mod (\n (tmpvar_1 * 2.0)\n , 1.0))))), u_mix);\n lowp vec4 tmpvar_3;\n tmpvar_3 = (tmpvar_2 + (u_color * (1.0 - tmpvar_2.w)));\n gl_FragColor = tmpvar_3;\n}\n\n", - }, - { - "precision highp float;\nattribute vec2 a_pos;\nuniform mat4 u_matrix;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n}\n\n", - "precision highp float;\nuniform vec4 u_color;\nvoid main ()\n{\n gl_FragColor = u_color;\n}\n\n", - }, - { - "precision highp float;\nuniform mat4 u_matrix;\nuniform float u_buffer;\nattribute vec2 a_pos;\nvarying vec2 v_pos;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n float tmpvar_2;\n tmpvar_2 = (4096.0 + (2.0 * u_buffer));\n v_pos = ((a_pos / tmpvar_2) + (u_buffer / tmpvar_2));\n}\n\n", - "precision highp float;\nuniform sampler2D u_image;\nuniform float u_opacity;\nvarying vec2 v_pos;\nvoid main ()\n{\n lowp vec4 tmpvar_1;\n tmpvar_1 = (texture2D (u_image, v_pos, 2.0) * u_opacity);\n gl_FragColor = tmpvar_1;\n}\n\n", - }, - { - "precision highp float;\nattribute vec2 a_pos;\nattribute vec2 a_offset;\nattribute vec4 a_data1;\nattribute vec4 a_data2;\nuniform mat4 u_matrix;\nuniform mat4 u_exmatrix;\nuniform float u_angle;\nuniform float u_zoom;\nuniform float u_flip;\nuniform float u_fadedist;\nuniform float u_minfadezoom;\nuniform float u_maxfadezoom;\nuniform float u_fadezoom;\nuniform vec2 u_texsize;\nvarying vec2 v_tex;\nvarying float v_alpha;\nvoid main ()\n{\n float rev_1;\n rev_1 = 0.0;\n float tmpvar_2;\n tmpvar_2 = (float(mod ((a_data1.w + u_angle), 256.0)));\n if ((((u_flip > 0.0) && (tmpvar_2 >= 64.0)) && (tmpvar_2 < 192.0))) {\n rev_1 = 1.0;\n };\n float tmpvar_3;\n tmpvar_3 = (((2.0 - \n float((u_zoom >= a_data2.x))\n ) - (1.0 - \n float((u_zoom >= a_data2.y))\n )) + rev_1);\n float tmpvar_4;\n tmpvar_4 = clamp (((u_fadezoom - a_data1.z) / u_fadedist), 0.0, 1.0);\n if ((u_fadedist >= 0.0)) {\n v_alpha = tmpvar_4;\n } else {\n v_alpha = (1.0 - tmpvar_4);\n };\n if ((u_maxfadezoom < a_data1.z)) {\n v_alpha = 0.0;\n };\n if ((u_minfadezoom >= a_data1.z)) {\n v_alpha = 1.0;\n };\n vec4 tmpvar_5;\n tmpvar_5.zw = vec2(0.0, 1.0);\n tmpvar_5.xy = a_pos;\n vec4 tmpvar_6;\n tmpvar_6.w = 0.0;\n tmpvar_6.xy = (a_offset / 64.0);\n tmpvar_6.z = ((tmpvar_3 + float(\n (0.0 >= v_alpha)\n )) + (float(\n (u_angle >= a_data2.z)\n ) * (1.0 - \n float((u_angle >= a_data2.w))\n )));\n gl_Position = ((u_matrix * tmpvar_5) + (u_exmatrix * tmpvar_6));\n v_tex = ((a_data1.xy * 4.0) / u_texsize);\n}\n\n", - "precision highp float;\nuniform sampler2D u_texture;\nuniform vec4 u_color;\nuniform float u_buffer;\nuniform float u_gamma;\nvarying vec2 v_tex;\nvarying float v_alpha;\nvoid main ()\n{\n float edge0_1;\n edge0_1 = (u_buffer - u_gamma);\n lowp float tmpvar_2;\n tmpvar_2 = clamp (((texture2D (u_texture, v_tex).w - edge0_1) / (\n (u_buffer + u_gamma)\n - edge0_1)), 0.0, 1.0);\n lowp vec4 tmpvar_3;\n tmpvar_3 = (u_color * ((tmpvar_2 * \n (tmpvar_2 * (3.0 - (2.0 * tmpvar_2)))\n ) * v_alpha));\n gl_FragColor = tmpvar_3;\n}\n\n", - } -}; -#endif diff --git a/src/util/transition.cpp b/src/util/transition.cpp index d15e3ef66..37177a935 100644 --- a/src/util/transition.cpp +++ b/src/util/transition.cpp @@ -2,7 +2,7 @@ #include #include -using namespace llmr::util; +namespace llmr { namespace util { UnitBezier ease(0.25, 0.1, 0.25, 1); @@ -74,3 +74,5 @@ transition::state ease_transition>::update(llmr::time now) return running; } } + +}}