--- a/test/sandbox.c Sun Jan 21 14:01:27 2024 +0100 +++ b/test/sandbox.c Tue Jan 23 21:34:12 2024 +0100 @@ -52,17 +52,18 @@ AscWindow *window = asc_window_initialize(0, &settings); asc_shader_initialize_predefined(); + // create fps counter and add it to the UI asc_set_font(asc_font(ASC_FONT_REGULAR, 24)); asc_ink_rgb(255, 0, 0); - AscText *fps_counter = asc_text(50, 50, "9999 FPS"); + AscText *fps_counter = asc_text(50, 50, "XXXXX FPS"); unsigned last_fps = 0; + asc_scene_add(&window->ui, asc_node(fps_counter)); - while (asc_loop_next()) { + do { // quit application on any error if (show_message_box_on_error(window->window)) break; - - // fps counter + // update fps counter if (asc_context.elapsed_millis > 0) { unsigned fps = 1000u / asc_context.elapsed_millis; if (fps != last_fps) { @@ -71,11 +72,7 @@ asc_text_update(fps_counter); } } - asc_text_draw(fps_counter); - } - - // TODO: maybe nodes should also be "garbage collected" - asc_text_free(fps_counter); + } while (asc_loop_next()); asc_context_destroy(); return 0;