WIP: Erreur lignes 668 & 671 (graphisme) si affichage Ok (semble Ok)

This commit is contained in:
Jean Sirmai 2023-11-03 15:15:05 +01:00
parent 0f7c8403ce
commit 988b2a41f2
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 20 additions and 13 deletions

View File

@ -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, 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) int console)
{ {
if (arrows_nb == 0) assert (buffer_lines_size == buffer_lines_0_arrow); // ? if (arrows_nb == 0) assert (buffer_lines_size == buffer_lines_0_arrow); // ?
@ -661,9 +661,8 @@ 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\ 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_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, \ arrows_nb + 1, arrows_nb, arrow_address_in_list, arrow_address_in_list, mem, arrows_nb, arrows_ptr[arrows_nb].site);
mem, arrows_ptr[arrows_nb].site, arrows_ptr[arrows_nb].site);
} }
for (long i = 0 + arrow_address_in_list * 6; i < 6 + arrow_address_in_list * 6; i++) for (long i = 0 + arrow_address_in_list * 6; i < 6 + arrow_address_in_list * 6; i++)
@ -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"); */ /* 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) print_arrows_array (arrows_ptr, arrows_nb, 0);
if (1) printf("\n");
return arrows_nb; 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; 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++) for (int i = 0; i < arrows_nb; i++)
if ((site == arrows_ptr[i].site) if ((site == arrows_ptr[i].site)
&& (arrow_x == arrows_ptr[i].x) && (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; break;
} }
assert (address <= arrows_nb); 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) 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); 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++) ; */ /* 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, 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, 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, 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, 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, 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, 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, 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); if (randomize) print_user_choices(arrows_ptr, max_arrows_nb, arrows_nb, space_X, space_Y, space_Z, 1, 0);