From 3489e8682089c71c42b30eca80d7230b2ecf44f8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 24 Oct 2021 08:05:50 +0200 Subject: Add clock --- tests/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') 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 #include #include +#include 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) -- cgit v1.2.3