This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathsymbol_vertex.hpp
54 lines (46 loc) · 1.57 KB
/
symbol_vertex.hpp
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
#pragma once
#include <mbgl/gl/attribute.hpp>
#include <array>
#include <cstdint>
#include <cmath>
namespace mbgl {
class SymbolVertex {
public:
SymbolVertex(int16_t x, int16_t y, float ox, float oy, uint16_t tx, uint16_t ty, float minzoom, float maxzoom, float labelminzoom, uint8_t labelangle)
: a_pos {
x,
y
},
a_offset {
static_cast<int16_t>(::round(ox * 64)), // use 1/64 pixels for placement
static_cast<int16_t>(::round(oy * 64))
},
a_texture_pos {
static_cast<uint16_t>(tx / 4),
static_cast<uint16_t>(ty / 4)
},
a_data {
static_cast<uint8_t>(labelminzoom * 10), // 1/10 zoom levels: z16 == 160
static_cast<uint8_t>(labelangle),
static_cast<uint8_t>(minzoom * 10),
static_cast<uint8_t>(::fmin(maxzoom, 25) * 10)
} {}
const int16_t a_pos[2];
const int16_t a_offset[2];
const uint16_t a_texture_pos[2];
const uint8_t a_data[4];
};
namespace gl {
template <class Shader>
struct AttributeBindings<Shader, SymbolVertex> {
std::array<AttributeBinding, 4> operator()(const Shader& shader) {
return {{
MBGL_MAKE_ATTRIBUTE_BINDING(SymbolVertex, shader, a_pos),
MBGL_MAKE_ATTRIBUTE_BINDING(SymbolVertex, shader, a_offset),
MBGL_MAKE_ATTRIBUTE_BINDING(SymbolVertex, shader, a_texture_pos),
MBGL_MAKE_ATTRIBUTE_BINDING(SymbolVertex, shader, a_data)
}};
};
};
} // namespace gl
} // namespace mbgl