aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/Text.cpp
blob: 094b1987b13579063a9e13a62067aea622c74b46 (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
#include "../../include/mglpp/graphics/Text.hpp"
#include "../../include/mglpp/graphics/Font.hpp"

extern "C" {
#include <mgl/mgl.h>
}

namespace mgl {
    Text::Text(const char *str, vec2f position, Font &font) : font(font) {
        mgl_text_init(&text, font.internal_font(), str, position.x, position.y);
    }

    Text::~Text() {
        mgl_text_deinit(&text);
    }

    void Text::set_position(vec2f position) {
        mgl_text_set_position(&text, {position.x, position.y});
    }

    void Text::set_color(Color color) {
        mgl_text_set_color(&text, {color.r, color.g, color.b, color.a});
    }

    vec2f Text::get_position() const {
        return { text.position.x, text.position.y };
    }

    void Text::draw(Window&) {
        mgl_text_draw(mgl_get_context(), &text);
    }
}