summaryrefslogtreecommitdiff
path: root/src/mbgl/programs/raster_program.hpp
blob: 9aa25cf90c41dc8439ad1e29d95d868f9551fd11 (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
67
#pragma once

#include <mbgl/programs/program.hpp>
#include <mbgl/programs/attributes.hpp>
#include <mbgl/programs/uniforms.hpp>
#include <mbgl/shader/raster.hpp>
#include <mbgl/util/geometry.hpp>

namespace mbgl {

namespace uniforms {
MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_image0);
MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_image1);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_fade_t);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_buffer_scale);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_brightness_low);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_brightness_high);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_saturation_factor);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_contrast_factor);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_scale_parent);
MBGL_DEFINE_UNIFORM_VECTOR(float, 3, u_spin_weights);
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_tl_parent);
} // namespace uniforms

using RasterAttributes = gl::Attributes<
    attributes::a_pos,
    attributes::a_texture_pos>;

class RasterProgram : public Program<
    shaders::raster,
    gl::Triangle,
    RasterAttributes,
    gl::Uniforms<
        uniforms::u_matrix,
        uniforms::u_image0,
        uniforms::u_image1,
        uniforms::u_opacity,
        uniforms::u_fade_t,
        uniforms::u_brightness_low,
        uniforms::u_brightness_high,
        uniforms::u_saturation_factor,
        uniforms::u_contrast_factor,
        uniforms::u_spin_weights,
        uniforms::u_buffer_scale,
        uniforms::u_scale_parent,
        uniforms::u_tl_parent>>
{
public:
    using Program::Program;

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

using RasterVertex = RasterProgram::Vertex;

} // namespace mbgl