test/sandbox.c

changeset 23
ab07757004b4
parent 22
30b12e88fd84
child 25
601b3f4e17a2
equal deleted inserted replaced
22:30b12e88fd84 23:ab07757004b4
52 AscWindow *window = asc_window_initialize(0, &settings); 52 AscWindow *window = asc_window_initialize(0, &settings);
53 asc_shader_initialize_predefined(); 53 asc_shader_initialize_predefined();
54 54
55 asc_set_font(asc_font(ASC_FONT_REGULAR, 24)); 55 asc_set_font(asc_font(ASC_FONT_REGULAR, 24));
56 asc_ink_rgb(255, 0, 0); 56 asc_ink_rgb(255, 0, 0);
57 AscTextNode *fps_counter = asc_text(50, 50, "60 FPS"); 57 AscTextNode *fps_counter = asc_text(50, 50, "9999 FPS");
58 unsigned last_fps = 0; 58 unsigned last_fps = 0;
59 59
60 while (asc_loop_next()) { 60 while (asc_loop_next()) {
61 // quit application on any error 61 // quit application on any error
62 if (show_message_box_on_error(window->window)) break; 62 if (show_message_box_on_error(window->window)) break;
65 // fps counter 65 // fps counter
66 if (asc_context.elapsed_millis > 0) { 66 if (asc_context.elapsed_millis > 0) {
67 unsigned fps = 1000u / asc_context.elapsed_millis; 67 unsigned fps = 1000u / asc_context.elapsed_millis;
68 if (fps != last_fps) { 68 if (fps != last_fps) {
69 last_fps = fps; 69 last_fps = fps;
70 cxBufferReset(&fps_counter->text); 70 snprintf(fps_counter->text, 9, "%u FPS", fps);
71 cx_bprintf(&fps_counter->text, "%u FPS", fps);
72 asc_text_update(fps_counter); 71 asc_text_update(fps_counter);
73 } 72 }
74 } 73 }
75 asc_text_draw(fps_counter); 74 asc_text_draw(fps_counter);
76 } 75 }

mercurial