summaryrefslogtreecommitdiff
path: root/src/mbgl/shader/circle_vertex.hpp
blob: 62e6e2da5bd8a6afbd71a99452544ae44930fe0c (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
#pragma once

#include <mbgl/gl/attribute.hpp>

#include <vector>
#include <cstdint>

namespace mbgl {

class CircleVertex {
public:
    /*
     * @param {number} x vertex position
     * @param {number} y vertex position
     * @param {number} ex extrude normal
     * @param {number} ey extrude normal
     */
    CircleVertex(int16_t x, int16_t y, float ex, float ey)
        : a_pos {
            static_cast<int16_t>((x * 2) + ((ex + 1) / 2)),
            static_cast<int16_t>((y * 2) + ((ey + 1) / 2))
        } {}

    const int16_t a_pos[2];
};

namespace gl {

template <class Shader>
struct AttributeBindings<Shader, CircleVertex> {
    std::vector<AttributeBinding> operator()(const Shader& shader) {
        return {{
            MBGL_MAKE_ATTRIBUTE_BINDING(CircleVertex, shader, a_pos)
        }};
    };
};

} // namespace gl
} // namespace mbgl