summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/draw_mode.hpp
blob: 275eb25b89f227b4e729a3f290886ef11376380b (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
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
69
70
71
72
73
74
75
76
77
78
79
#pragma once

#include <mbgl/gl/types.hpp>
#include <mbgl/gl/primitives.hpp>

#include <cassert>

namespace mbgl {
namespace gl {

class Points {
public:
    using Primitive = Point;

    static constexpr std::size_t bufferGroupSize = 1;
    static constexpr PrimitiveType primitiveType = PrimitiveType::Points;

    explicit Points(float pointSize_) : pointSize(pointSize_) {}

    float pointSize;
};

class Lines {
public:
    using Primitive = Line;

    static constexpr std::size_t bufferGroupSize = 2;
    static constexpr PrimitiveType primitiveType = PrimitiveType::Lines;

    explicit Lines(float lineWidth_) : lineWidth(lineWidth_) {
        assert(lineWidth > 0);
    }

    float lineWidth;
};

class LineStrip {
public:
    // LineStrip is a form of "Line" rendering, but the element buffer
    // cannot be grouped into logical elements beyond a single Point.
    using Primitive = Line;

    static constexpr std::size_t bufferGroupSize = 1;
    static constexpr PrimitiveType primitiveType = PrimitiveType::LineStrip;

    explicit LineStrip(float lineWidth_) : lineWidth(lineWidth_) {
        assert(lineWidth > 0);
    }

    float lineWidth;
};

class Triangles {
public:
    using Primitive = Triangle;

    static constexpr std::size_t bufferGroupSize = 3;
    static constexpr PrimitiveType primitiveType = PrimitiveType::Triangles;
};

class TriangleStrip {
public:
    // TriangleStrip is a form of "Triangle" rendering, but the element buffer
    // cannot be grouped into logical elements beyond a single Point.
    using Primitive = Triangle;

    static constexpr std::size_t bufferGroupSize = 1;
    static constexpr PrimitiveType primitiveType = PrimitiveType::TriangleStrip;
};

// Special draw mode for use with VertexVector<Indexed, Vertex>, in which
// case the true draw mode is denoted by the IndexVector type.
class Indexed {
public:
    static constexpr std::size_t bufferGroupSize = 1;
};

} // namespace gl
} // namespace mbgl