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
68
|
#include <mbgl/renderer/render_static_data.hpp>
#include <mbgl/gfx/context.hpp>
#include <mbgl/programs/program_parameters.hpp>
namespace mbgl {
static gfx::VertexVector<gfx::Vertex<PositionOnlyLayoutAttributes>> tileVertices() {
gfx::VertexVector<gfx::Vertex<PositionOnlyLayoutAttributes>> result;
result.emplace_back(gfx::Vertex<PositionOnlyLayoutAttributes>({{{ 0, 0 }}}));
result.emplace_back(gfx::Vertex<PositionOnlyLayoutAttributes>({{{ util::EXTENT, 0 }}}));
result.emplace_back(gfx::Vertex<PositionOnlyLayoutAttributes>({{{ 0, util::EXTENT }}}));
result.emplace_back(gfx::Vertex<PositionOnlyLayoutAttributes>({{{ util::EXTENT, util::EXTENT }}}));
return result;
}
static gfx::IndexVector<gfx::Triangles> quadTriangleIndices() {
gfx::IndexVector<gfx::Triangles> result;
result.emplace_back(0, 1, 2);
result.emplace_back(1, 2, 3);
return result;
}
static gfx::IndexVector<gfx::LineStrip> tileLineStripIndices() {
gfx::IndexVector<gfx::LineStrip> result;
result.emplace_back(0);
result.emplace_back(1);
result.emplace_back(3);
result.emplace_back(2);
result.emplace_back(0);
return result;
}
static gfx::VertexVector<RasterLayoutVertex> rasterVertices() {
gfx::VertexVector<RasterLayoutVertex> result;
result.emplace_back(RasterProgram::layoutVertex({ 0, 0 }, { 0, 0 }));
result.emplace_back(RasterProgram::layoutVertex({ util::EXTENT, 0 }, { util::EXTENT, 0 }));
result.emplace_back(RasterProgram::layoutVertex({ 0, util::EXTENT }, { 0, util::EXTENT }));
result.emplace_back(RasterProgram::layoutVertex({ util::EXTENT, util::EXTENT }, { util::EXTENT, util::EXTENT }));
return result;
}
static gfx::VertexVector<ExtrusionTextureLayoutVertex> extrusionTextureVertices() {
gfx::VertexVector<ExtrusionTextureLayoutVertex> result;
result.emplace_back(ExtrusionTextureProgram::layoutVertex({ 0, 0 }));
result.emplace_back(ExtrusionTextureProgram::layoutVertex({ 1, 0 }));
result.emplace_back(ExtrusionTextureProgram::layoutVertex({ 0, 1 }));
result.emplace_back(ExtrusionTextureProgram::layoutVertex({ 1, 1 }));
return result;
}
RenderStaticData::RenderStaticData(gfx::Context& context, float pixelRatio, const optional<std::string>& programCacheDir)
: tileVertexBuffer(context.createVertexBuffer(tileVertices())),
rasterVertexBuffer(context.createVertexBuffer(rasterVertices())),
extrusionTextureVertexBuffer(context.createVertexBuffer(extrusionTextureVertices())),
quadTriangleIndexBuffer(context.createIndexBuffer(quadTriangleIndices())),
tileBorderIndexBuffer(context.createIndexBuffer(tileLineStripIndices())),
programs(context, ProgramParameters { pixelRatio, false, programCacheDir })
#ifndef NDEBUG
, overdrawPrograms(context, ProgramParameters { pixelRatio, true, programCacheDir })
#endif
{
tileTriangleSegments.emplace_back(0, 0, 4, 6);
tileBorderSegments.emplace_back(0, 0, 4, 5);
rasterSegments.emplace_back(0, 0, 4, 6);
extrusionTextureSegments.emplace_back(0, 0, 4, 6);
}
} // namespace mbgl
|