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
|
#pragma once
#include <mbgl/gl/attribute.hpp>
#include <vector>
#include <cstdint>
#include <cmath>
namespace mbgl {
class CollisionBoxVertex {
public:
CollisionBoxVertex(int16_t x, int16_t y, float ox, float oy, float maxzoom, float placementZoom)
: a_pos { x, y },
a_extrude {
static_cast<int16_t>(::round(ox)),
static_cast<int16_t>(::round(oy))
},
a_data {
static_cast<uint8_t>(maxzoom * 10),
static_cast<uint8_t>(placementZoom * 10)
} {}
const int16_t a_pos[2];
const int16_t a_extrude[2];
const uint8_t a_data[2];
};
namespace gl {
template <class Shader>
struct AttributeBindings<Shader, CollisionBoxVertex> {
std::vector<AttributeBinding> operator()(const Shader& shader) {
return {{
MBGL_MAKE_ATTRIBUTE_BINDING(CollisionBoxVertex, shader, a_pos),
MBGL_MAKE_ATTRIBUTE_BINDING(CollisionBoxVertex, shader, a_extrude),
MBGL_MAKE_ATTRIBUTE_BINDING(CollisionBoxVertex, shader, a_data)
}};
};
};
} // namespace gl
} // namespace mbgl
|