aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/main.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/main.c b/tests/main.c
index 478e432..be7fcdd 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -4,9 +4,12 @@
#include <mgl/graphics/texture.h>
#include <mgl/graphics/rectangle.h>
#include <mgl/graphics/sprite.h>
+#include <mgl/graphics/font.h>
+#include <mgl/graphics/text.h>
typedef struct {
mgl_texture *texture;
+ mgl_font *font;
} Userdata;
static void draw(mgl_window *window, void *userdata) {
@@ -24,6 +27,11 @@ static void draw(mgl_window *window, void *userdata) {
mgl_sprite_init(&sprite, u->texture, 100.0f - 10.0f, 0.0f);
mgl_sprite_set_color(&sprite, 1.0f, 1.0f, 1.0f, 0.5f);
mgl_sprite_draw(context, &sprite);
+
+ mgl_text text;
+ mgl_text_init(&text, u->font, "hello world!\nGood bye world!", 0.0f, 0.0f);
+ mgl_text_draw(context, &text);
+ mgl_text_deinit(&text);
}
int main(int argc, char **argv) {
@@ -31,9 +39,11 @@ int main(int argc, char **argv) {
return 1;
mgl_texture texture;
+ mgl_font font;
Userdata userdata;
userdata.texture = &texture;
+ userdata.font = &font;
mgl_window_callback window_callback;
window_callback.userdata = &userdata;
@@ -46,11 +56,15 @@ int main(int argc, char **argv) {
if(mgl_texture_load_from_file(&texture, "X11.png", NULL) != 0)
return 1;
+ if(mgl_font_load_from_file(&font, "/usr/share/fonts/noto/NotoSans-Regular.ttf", 32) != 0)
+ return 1;
+
for(;;) {
mgl_window_events_poll(&window);
mgl_window_draw(&window);
}
+ mgl_font_unload(&font);
mgl_texture_unload(&texture);
mgl_window_deinit(&window);
mgl_deinit();