1 #pragma once
2 
3 #include <mbgl/programs/program.hpp>
4 #include <mbgl/programs/attributes.hpp>
5 #include <mbgl/programs/uniforms.hpp>
6 #include <mbgl/shaders/heatmap.hpp>
7 #include <mbgl/util/geometry.hpp>
8 #include <mbgl/style/layers/heatmap_layer_properties.hpp>
9 
10 namespace mbgl {
11 
12 namespace uniforms {
13 MBGL_DEFINE_UNIFORM_SCALAR(float, u_intensity);
14 } // namespace uniforms
15 
16 class HeatmapProgram : public Program<
17     shaders::heatmap,
18     gl::Triangle,
19     gl::Attributes<
20         attributes::a_pos>,
21     gl::Uniforms<
22         uniforms::u_intensity,
23         uniforms::u_matrix,
24         uniforms::heatmap::u_extrude_scale>,
25     style::HeatmapPaintProperties>
26 {
27 public:
28     using Program::Program;
29 
30     /*
31      * @param {number} x vertex position
32      * @param {number} y vertex position
33      * @param {number} ex extrude normal
34      * @param {number} ey extrude normal
35      */
vertex(Point<int16_t> p,float ex,float ey)36     static LayoutVertex vertex(Point<int16_t> p, float ex, float ey) {
37         return LayoutVertex {
38             {{
39                 static_cast<int16_t>((p.x * 2) + ((ex + 1) / 2)),
40                 static_cast<int16_t>((p.y * 2) + ((ey + 1) / 2))
41             }}
42         };
43     }
44 };
45 
46 using HeatmapLayoutVertex = HeatmapProgram::LayoutVertex;
47 using HeatmapAttributes = HeatmapProgram::Attributes;
48 
49 } // namespace mbgl
50