summaryrefslogtreecommitdiffhomepage
path: root/draw/box.hpp
blob: 82d946d839adee33f03c53b38a869fe67a724fa6 (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
#pragma once
#include <array>
#include <Corrade/Containers/ArrayView.h>
#include <Magnum/Math/Vector3.h>
#include <Magnum/GL/Mesh.h>

namespace floormat::wireframe {

struct box
{
    box(Vector3 center, Vector3 size, float line_width);

    static constexpr size_t num_vertices = 8, num_indexes = 12*2;
    static constexpr GL::MeshPrimitive primitive = GL::MeshPrimitive::Lines;

    using vertex_array = std::array<Vector3, num_vertices>;
    using index_array = std::array<UnsignedShort, num_indexes>;

    vertex_array make_vertex_array() const;
    static index_array make_index_array();
    void on_draw() const;

private:
    Vector3 center;
    Vector3 size;
    float line_width = 2;
};

} // namespace floormat::wireframe