diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 6b4985b..b641468 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -638,7 +638,7 @@ static inline int create_arrow (int arrows_nb, } static inline int erase_arrow (int arrows_nb, int arrow_address_in_list, - int site, int x, int y, int z, + GLuint site, GLint x, GLint y, GLint z, int console) { if (arrows_nb == 0) assert (buffer_lines_size == buffer_lines_0_arrow); // ? @@ -661,16 +661,15 @@ static inline int erase_arrow (int arrows_nb, int arrow_address_in_list, if (console) printf("in erase_arrow() : arrows_nb decreases from %d to %d. the erased arrow was at address : %d\n\ - : arrows_ptr[%d].site (value: %d) was replaced by %d (%d was the value of the last arrow.site)\n",\ - arrows_nb + 1, arrows_nb, arrow_address_in_list, arrow_address_in_list, \ - mem, arrows_ptr[arrows_nb].site, arrows_ptr[arrows_nb].site); + : arrows_ptr[%d].site (value: %d) was replaced by arrows_ptr[%d].site (value: %d)\n",\ + arrows_nb + 1, arrows_nb, arrow_address_in_list, arrow_address_in_list, mem, arrows_nb, arrows_ptr[arrows_nb].site); } - for (long i = 0 + arrow_address_in_list * 6; i < 6 + arrow_address_in_list * 6; i++) - buffer_vertex_origin [buffer_vertex_0_arrow + i] = buffer_vertex_origin [buffer_vertex_size - 6 + i]; + for (long i = 0 + arrow_address_in_list * 6; i < 6 + arrow_address_in_list * 6; i++) + buffer_vertex_origin [buffer_vertex_0_arrow + i] = buffer_vertex_origin [buffer_vertex_size - 6 + i]; - for (long i = 0 + arrow_address_in_list * 6; i < 6 + arrow_address_in_list * 6; i++) - buffer_colors_origin [buffer_colors_0_arrow + i] = buffer_colors_origin [buffer_colors_size - 6 + i]; + for (long i = 0 + arrow_address_in_list * 6; i < 6 + arrow_address_in_list * 6; i++) + buffer_colors_origin [buffer_colors_0_arrow + i] = buffer_colors_origin [buffer_colors_size - 6 + i]; buffer_vertex_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_write_vertex() buffer_colors_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_write_colors() @@ -690,6 +689,7 @@ static inline int erase_arrow (int arrows_nb, int arrow_address_in_list, /* else perror("In graphics.erase_arrow(), can't re_allocate for arrows lines buffer.\n"); */ if (1) print_arrows_array (arrows_ptr, arrows_nb, 0); + if (1) printf("\n"); return arrows_nb; } @@ -701,6 +701,9 @@ static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb, int spac { int address = -1, current_weight = -1; + printf("in set_arrow (begin) arrows_nb = %d requested site: %d > ", arrows_nb, site); + for (int i = 0; i < arrows_nb; i++) {printf(" [%d] = %d ", i, arrows_ptr[i].site); if (site == arrows_ptr[i].site) break;} + for (int i = 0; i < arrows_nb; i++) if ((site == arrows_ptr[i].site) && (arrow_x == arrows_ptr[i].x) @@ -712,6 +715,10 @@ static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb, int spac break; } assert (address <= arrows_nb); + if (address == -1 && requested_weight > 0) printf(" >> create_arrow() at site %d\n", site); + if (address >= 0 && requested_weight == 0) printf(" >> erase_arrow() at site %d\n", site); + if (address >= 0 && current_weight != requested_weight) printf(" >> rewrite_arrow() at site %d\n", site); + if (address == -1 && requested_weight == 0) printf(" >> no operation\n"); if (address == -1 && requested_weight > 0) return create_arrow (arrows_nb, space_X, space_Y, space_Z, requested_weight, site, arrow_x, arrow_y, arrow_z, console); @@ -779,11 +786,11 @@ void main_test_graphics (void) /* else for (int i = 0; i < 1; i++) ; */ arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, 0, 0, 0, 0, 1); arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, 1, 0, 0, 0, 1); - arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, 2, 0, 0, 0, 1); - arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, 3, 0, 0, 0, 1); - arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, 4, 0, 0, 0, 1); - arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, 5, 0, 0, 0, 1); - arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, 6, 0, 0, 0, 1); + /* arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, 2, 0, 0, 0, 1); */ + /* arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, 3, 0, 0, 0, 1); */ + /* arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, 4, 0, 0, 0, 1); */ + /* arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, 5, 0, 0, 0, 1); */ + /* arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, 6, 0, 0, 0, 1); */ if (randomize) print_user_choices(arrows_ptr, max_arrows_nb, arrows_nb, space_X, space_Y, space_Z, 1, 0);