1.1 --- a/test/sandbox.c Sun Jan 21 14:01:27 2024 +0100 1.2 +++ b/test/sandbox.c Tue Jan 23 21:34:12 2024 +0100 1.3 @@ -52,17 +52,18 @@ 1.4 AscWindow *window = asc_window_initialize(0, &settings); 1.5 asc_shader_initialize_predefined(); 1.6 1.7 + // create fps counter and add it to the UI 1.8 asc_set_font(asc_font(ASC_FONT_REGULAR, 24)); 1.9 asc_ink_rgb(255, 0, 0); 1.10 - AscText *fps_counter = asc_text(50, 50, "9999 FPS"); 1.11 + AscText *fps_counter = asc_text(50, 50, "XXXXX FPS"); 1.12 unsigned last_fps = 0; 1.13 + asc_scene_add(&window->ui, asc_node(fps_counter)); 1.14 1.15 - while (asc_loop_next()) { 1.16 + do { 1.17 // quit application on any error 1.18 if (show_message_box_on_error(window->window)) break; 1.19 1.20 - 1.21 - // fps counter 1.22 + // update fps counter 1.23 if (asc_context.elapsed_millis > 0) { 1.24 unsigned fps = 1000u / asc_context.elapsed_millis; 1.25 if (fps != last_fps) { 1.26 @@ -71,11 +72,7 @@ 1.27 asc_text_update(fps_counter); 1.28 } 1.29 } 1.30 - asc_text_draw(fps_counter); 1.31 - } 1.32 - 1.33 - // TODO: maybe nodes should also be "garbage collected" 1.34 - asc_text_free(fps_counter); 1.35 + } while (asc_loop_next()); 1.36 1.37 asc_context_destroy(); 1.38 return 0;