diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-18 01:54:59 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-18 01:54:59 +0200 |
commit | 3e081d1669622bbc276b038ddc38ecf0600683c3 (patch) | |
tree | 0a92c34f257c75a2b26e63b0ea9da3d594e89cc8 /src/graphics/Text.cpp |
Initial commit with an example
Diffstat (limited to 'src/graphics/Text.cpp')
-rw-r--r-- | src/graphics/Text.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/graphics/Text.cpp b/src/graphics/Text.cpp new file mode 100644 index 0000000..e598b2f --- /dev/null +++ b/src/graphics/Text.cpp @@ -0,0 +1,28 @@ +#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}); + } + + void Text::draw(Window&) { + mgl_text_draw(mgl_get_context(), &text); + } +}
\ No newline at end of file |