summaryrefslogtreecommitdiff
path: root/src/mbgl/shader/circle_attributes.hpp
blob: 92f8ff1e5c1f04426cc8ab359d23f9f942d879be (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
#pragma once

#include <mbgl/shader/attributes.hpp>
#include <mbgl/util/geometry.hpp>

namespace mbgl {

struct CircleAttributes : gl::Attributes<
    attributes::a_pos>
{
    /*
     * @param {number} x vertex position
     * @param {number} y vertex position
     * @param {number} ex extrude normal
     * @param {number} ey extrude normal
     */
    static Vertex vertex(Point<int16_t> p, float ex, float ey) {
        return Vertex {
            {
                static_cast<int16_t>((p.x * 2) + ((ex + 1) / 2)),
                static_cast<int16_t>((p.y * 2) + ((ey + 1) / 2))
            }
        };
    }
};

using CircleVertex = CircleAttributes::Vertex;
static_assert(sizeof(CircleVertex) == 4, "expected CircleVertex size");

} // namespace mbgl