aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-24 08:05:50 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-26 11:09:20 +0200
commit3489e8682089c71c42b30eca80d7230b2ecf44f8 (patch)
tree2413cb5bec912ab8213d4dc22bb69ea4467bb737 /tests
parent115630b520668304af1ccd3eb0b13c06e17ecccc (diff)
Add clock
Diffstat (limited to 'tests')
-rw-r--r--tests/main.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/main.c b/tests/main.c
index 0001288..bffbf96 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -9,12 +9,14 @@
#include <mgl/graphics/text.h>
#include <mgl/graphics/vertex_buffer.h>
#include <mgl/graphics/shader.h>
+#include <mgl/system/clock.h>
typedef struct {
mgl_texture *texture;
mgl_font *font;
mgl_vertex_buffer *vertex_buffer;
mgl_shader_program *shader_program;
+ mgl_clock clock;
} Userdata;
static void draw(mgl_window *window, void *userdata) {
@@ -37,8 +39,11 @@ static void draw(mgl_window *window, void *userdata) {
mgl_sprite_draw(context, &sprite);
mgl_shader_program_use(NULL);
+ char str[255];
+ snprintf(str, sizeof(str), "Hello world!\nelapsed time: %f", mgl_clock_get_elapsed_time_seconds(&u->clock));
+
mgl_text text;
- mgl_text_init(&text, u->font, "hello world!\nGood bye world!", 0.0f, 0.0f);
+ mgl_text_init(&text, u->font, str, 0.0f, 0.0f);
mgl_text_draw(context, &text);
mgl_text_deinit(&text);
@@ -60,6 +65,7 @@ int main(int argc, char **argv) {
userdata.font = &font;
userdata.vertex_buffer = &vertex_buffer;
userdata.shader_program = &shader_program;
+ mgl_clock_init(&userdata.clock);
mgl_window window;
if(mgl_window_create(&window, "mgl", 1280, 720) != 0)