summaryrefslogtreecommitdiffhomepage
path: root/editor/draw.cpp
blob: 8273fc44e7fe2f538cf423bd8c5c894cdd1385d0 (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
#include "app.hpp"
#include "floormat/main.hpp"
#include "floormat/settings.hpp"
#include "shaders/tile.hpp"
#include <Magnum/Math/Vector3.h>

namespace floormat {

void app::draw_cursor()
{
    constexpr float LINE_WIDTH = 2;

    if (const auto [pos, b] = cursor.tile; b && !cursor.in_imgui)
    {
        const auto draw = [&, pos = pos](auto& mesh, const auto& size) {
            const auto pt = pos.to_signed();
            const Vector3 center{Vector3i(pt[0], pt[1], 0) * iTILE_SIZE};
            auto& shader = M->shader();
            shader.set_tint({1, 0, 0, 1});
            mesh.draw(shader, {center, size, LINE_WIDTH});
        };

        if (const auto* ed = _editor.current_tile_editor(); ed && ed->mode() == editor_mode::walls)
            switch (ed->rotation())
            {
            case editor_wall_rotation::N: draw(_wireframe_wall_n, TILE_SIZE); break;
            case editor_wall_rotation::W: draw(_wireframe_wall_w, TILE_SIZE); break;
            }
        else
            draw(_wireframe_quad, TILE_SIZE2);
    }
}

void app::draw_msaa()
{
    draw_cursor();
}

void app::draw()
{
    draw_ui();
    render_menu();
}

} // namespace floormat