diff -r 00c0632f0f40 -r d0e88022e209 test/sandbox.c --- a/test/sandbox.c Sun Nov 19 13:27:08 2023 +0100 +++ b/test/sandbox.c Thu Nov 23 23:08:57 2023 +0100 @@ -52,7 +52,9 @@ AscWindow *window = asc_window_initialize(0, &settings); asc_shader_initialize_predefined(); - AscTextNode fps_counter = {0}; + asc_set_font(asc_font(ASC_FONT_REGULAR, 24)); + asc_ink_rgb(255, 0, 0); + AscTextNode *fps_counter = asc_text(50, 50, "60 FPS"); unsigned last_fps = 0; while (asc_loop_next()) { @@ -65,19 +67,16 @@ unsigned fps = 1000u / asc_context.elapsed_millis; if (fps != last_fps) { last_fps = fps; - asc_set_font(asc_font(ASC_FONT_REGULAR, 24)); - asc_ink_rgb(255, 0, 0); - cxmutstr fpstext = cx_asprintf("%u FPS", fps); - asc_text_draw(&fps_counter, (asc_vec2i) {50, 50}, fpstext); - cx_strfree(&fpstext); - } else { - asc_text_redraw(&fps_counter); + cxBufferClear(&fps_counter->text); + cx_bprintf(&fps_counter->text, "%u FPS", fps); + asc_text_update(fps_counter); } } + asc_text_draw(fps_counter); } // TODO: maybe nodes should also be "garbage collected" - asc_text_destroy(&fps_counter); + asc_text_free(fps_counter); asc_context_destroy(); return 0;