summaryrefslogtreecommitdiff
path: root/src/mbgl/programs/hillshade_program.hpp
blob: 68d67917dfce0adb9efe5c0e36e9e2a7f884d9f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once

#include <mbgl/programs/program.hpp>
#include <mbgl/programs/attributes.hpp>
#include <mbgl/programs/hillshade_prepare_program.hpp>
#include <mbgl/programs/uniforms.hpp>
#include <mbgl/programs/textures.hpp>
#include <mbgl/util/geometry.hpp>
#include <mbgl/style/layers/hillshade_layer_properties.hpp>

namespace mbgl {

namespace uniforms {
MBGL_DEFINE_UNIFORM_SCALAR(Color, u_shadow);
MBGL_DEFINE_UNIFORM_SCALAR(Color, u_highlight);
MBGL_DEFINE_UNIFORM_SCALAR(Color, u_accent);
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_light);
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_latrange);
} // namespace uniforms

class HillshadeProgram : public Program<
    HillshadeProgram,
    gfx::PrimitiveType::Triangle,
    TypeList<
        attributes::a_pos,
        attributes::a_texture_pos>,
    TypeList<
        uniforms::u_matrix,
        uniforms::u_highlight,
        uniforms::u_shadow,
        uniforms::u_accent,
        uniforms::u_light,
        uniforms::u_latrange>,
    TypeList<
        textures::u_image>,
    style::HillshadePaintProperties>{
public:
    using Program::Program;

    static LayoutVertex layoutVertex(Point<int16_t> p, Point<uint16_t> t) {
        return LayoutVertex {
            {{
                p.x,
                p.y
            }},
            {{
                t.x,
                t.y
            }}
        };
    }
};

using HillshadeLayoutVertex = HillshadeProgram::LayoutVertex;
using HillshadeAttributes = HillshadeProgram::AttributeList;

class HillshadeLayerPrograms final : public LayerTypePrograms  {
public:
    HillshadeLayerPrograms(gfx::Context& context, const ProgramParameters& programParameters)
        : hillshade(context, programParameters),
          hillshadePrepare(context, programParameters) {}
    HillshadeProgram hillshade;
    HillshadePrepareProgram hillshadePrepare;
};

} // namespace mbgl