summaryrefslogtreecommitdiff
path: root/src/geometry/line_buffer.cpp
blob: a80ded5fbed4c31d569b9c5585937efbc4c6ad3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <llmr/geometry/line_buffer.hpp>
#include <llmr/platform/gl.hpp>

#include <cmath>

using namespace llmr;

size_t LineVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar) {
    size_t idx = index();
    void *data = addElement();

    int16_t *coords = static_cast<int16_t *>(data);
    coords[0] = (x * 2) | tx;
    coords[1] = (y * 2) | ty;

    int8_t *extrude = static_cast<int8_t *>(data);
    extrude[4] = std::round(extrudeScale * ex);
    extrude[5] = std::round(extrudeScale * ey);

    coords[3] = linesofar;

    return idx;
}