From 3e081d1669622bbc276b038ddc38ecf0600683c3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 18 Oct 2021 01:54:59 +0200 Subject: Initial commit with an example --- src/graphics/Text.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/graphics/Text.cpp (limited to 'src/graphics/Text.cpp') 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 +} + +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 -- cgit v1.2.3