aboutsummaryrefslogtreecommitdiff
path: root/src/gui/Utils.cpp
blob: e000b7aa61b836cf1595fa21d17dbb31cd588eb5 (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
#include "../../include/gui/Utils.hpp"
#include <mglpp/window/Window.hpp>
#include <mglpp/graphics/Rectangle.hpp>

namespace gsr {
    static double frame_delta_seconds = 1.0;

    // TODO: Use vertices to make it one draw call
    void draw_rectangle_outline(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size, mgl::Color color, float border_size) {
        pos = pos.floor();
        size = size.floor();
        border_size = (int)border_size;
        // Green line at top
        {
            mgl::Rectangle rect({ size.x, border_size });
            rect.set_position(pos);
            rect.set_color(color);
            window.draw(rect);
        }

        // Green line at bottom
        {
            mgl::Rectangle rect({ size.x, border_size });
            rect.set_position(pos + mgl::vec2f(0.0f, size.y - border_size));
            rect.set_color(color);
            window.draw(rect);
        }

        // Green line at left
        {
            mgl::Rectangle rect({ border_size, size.y - border_size * 2 });
            rect.set_position(pos + mgl::vec2f(0, border_size));
            rect.set_color(color);
            window.draw(rect);
        }

        // Green line at right
        {
            mgl::Rectangle rect({ border_size, size.y - border_size * 2 });
            rect.set_position(pos + mgl::vec2f(size.x - border_size, border_size));
            rect.set_color(color);
            window.draw(rect);
        }
    }

    double get_frame_delta_seconds() {
        return frame_delta_seconds;
    }

    void set_frame_delta_seconds(double frame_delta) {
        frame_delta_seconds = frame_delta;
    }
}