summaryrefslogtreecommitdiff
path: root/src/mbgl/geometry/elements_buffer.hpp
blob: ce716dfaf4a8b4d0265e164c4a67c7546564f7bb (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
#ifndef MBGL_GEOMETRY_TRIANGLE_ELEMENTS_BUFFER
#define MBGL_GEOMETRY_TRIANGLE_ELEMENTS_BUFFER

#include <mbgl/geometry/buffer.hpp>
#include <mbgl/geometry/vao.hpp>

#include <mbgl/util/noncopyable.hpp>

#include <array>

namespace mbgl {

template <GLsizei count>
struct ElementGroup : public util::noncopyable {
    std::array<VertexArrayObject, count> array;
    GLsizei vertex_length;
    GLsizei elements_length;

    ElementGroup(GLsizei vertex_length_ = 0, GLsizei elements_length_ = 0)
        : vertex_length(vertex_length_)
        , elements_length(elements_length_)
    {
    }
};

class TriangleElementsBuffer : public Buffer<
    6, // bytes per triangle (3 * unsigned short == 6 bytes)
    GL_ELEMENT_ARRAY_BUFFER
> {
public:
    typedef uint16_t element_type;

    void add(element_type a, element_type b, element_type c);
};


class LineElementsBuffer : public Buffer<
    4, // bytes per triangle (2 * unsigned short == 6 bytes)
    GL_ELEMENT_ARRAY_BUFFER
> {
public:
    typedef uint16_t element_type;

    void add(element_type a, element_type b);
};

} // namespace mbgl

#endif